Debian Codegraph @

examples/demo_splitre

raw
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 re = "if|then|else|while|do|end"
12 re = re "|" "[0-9]+([.][0-9]+)?"
13 re = re "|" ":=|=|<|>|!=|[+]|-|[*]|/|[.][.]"
14 re = re "|" "[()]"
15 re = re "|" "[[:alpha:]_][[:alnum:]_]*"
16 re = re "|" "'[^']*'"
17 }
18
19 {
20 cnt = splitre0(arr, re)
21 for (i=1; i <= cnt; ++i){
22 print arr [i]
23 }
24 print "<NL>"
25 }