diff options
Diffstat (limited to 'test/backtrack3.lm')
-rw-r--r-- | test/backtrack3.lm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/backtrack3.lm b/test/backtrack3.lm new file mode 100644 index 0000000..8c6dfc3 --- /dev/null +++ b/test/backtrack3.lm @@ -0,0 +1,34 @@ +##### LM ##### + +# Token names. +lex + token number /[0-9]+/ + token id /[a-z]+/ + token string /'"' [^"]* '"'/ + ignore ws / [ \t\n]+ / +end + +def prefix [id] + +def choice1 + [number number] +| [number] + +def choice2 + [string id] +| [number number] +| [id number] +| [number] + +def start + [prefix choice1 choice2 string id id] + { + print_xml( match lhs "id 77 88 \"hello\" dude dude\n" ) + } + +parse start[stdin] +print( '\n' ) +##### IN ##### +id 77 88 "hello" dude dude +##### EXP ##### +<start><prefix><id>id</id></prefix><choice1><number>77</number></choice1><choice2><number>88</number></choice2><string>"hello"</string><id>dude</id><id>dude</id></start> |