| 1 |
#!/usr/bin/env runawk |
| 2 |
|
| 3 |
#use "tokenre.awk" |
| 4 |
|
| 5 |
# This demo splits input line into tokens according to regexp that |
| 6 |
# defines lexem of hypotetic programming language. |
| 7 |
|
| 8 |
# Input files for this demo: examples/demo_tokenre2.in* |
| 9 |
|
| 10 |
BEGIN { |
| 11 |
TRE = "if|then|else|while|do|end" |
| 12 |
TRE = TRE "|" "[0-9]+([.][0-9]+)?" |
| 13 |
TRE = TRE "|" ":=|=|<|>|!=|[+]|-|[*]|/|[.][.]" |
| 14 |
TRE = TRE "|" "[()]" |
| 15 |
TRE = TRE "|" "[[:alpha:]_][[:alnum:]_]*" |
| 16 |
TRE = TRE "|" "'[^']*'" |
| 17 |
} |
| 18 |
|
| 19 |
{ |
| 20 |
for (i=1; i <= NF; ++i){ |
| 21 |
print $i |
| 22 |
} |
| 23 |
print "<NL>" |
| 24 |
} |