Tokenize a string with escaping: Difference between revisions
Content added Content deleted
m (→{{header|Sidef}}: this output is incorrect) |
(→{{header|TMG}}: new section) |
||
Line 2,176: | Line 2,176: | ||
{{out}} |
{{out}} |
||
<pre>one|uno {} three^^ four^|cuatro {}</pre> |
<pre>one|uno {} three^^ four^|cuatro {}</pre> |
||
=={{header|TMG}}== |
|||
Unix TMG: |
|||
<lang UnixTMG>prog: char(sep) * |
|||
char(esc) * |
|||
str: smark |
|||
token: forw/outp |
|||
( [ch==esc?] char(ch) any(!<<>>) token |
|||
| [ch==sep?] char(ch) outp str |
|||
| any(!<<>>) token ); |
|||
outp: parse(( scopy = { <"> 1 <"> * } )); |
|||
forw: peek/chkeof; |
|||
peek: [ch=0] char(ch) fail; |
|||
chkeof: ( [ch?] succ | fail ); |
|||
ch: 0; |
|||
sep: 0; |
|||
esc: 0;</lang> |
|||
Input: |
|||
<pre>| |
|||
^ |
|||
one^|uno||three^^^^|four^^^|^cuatro|</pre> |
|||
Output: |
|||
<pre>"one|uno" |
|||
"" |
|||
"three^^" |
|||
"four^|cuatro" |
|||
""</pre> |
|||
=={{header|VBA}}== |
=={{header|VBA}}== |