diff options
Diffstat (limited to 'test/undofrag1.lm')
-rw-r--r-- | test/undofrag1.lm | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/undofrag1.lm b/test/undofrag1.lm new file mode 100644 index 0000000..a997cb8 --- /dev/null +++ b/test/undofrag1.lm @@ -0,0 +1,67 @@ +##### LM ##### + +lex + ignore /space+/ + literal `# `{ `} + token id2 /[a-zA-Z_]+/ +end + +def item2 + [id2] +| [`{ item2* `}] + +def start2 + [item2*] + + +context ctx + + SP: parser<start2> + + lex + ignore /space+/ + literal `* `( `) `! + token semi_nl /';\n'/ + token id /[a-zA-Z_]+/ + end + + def item + [id] + | [`( item* `)] + + + def A [] { + print( 'A\n' ) + send SP "{ A{d} }" + } + + def B [] { + print( 'B\n' ) + send SP "{ B{d} }" + } + + def start1 + [A item* `!] + | [B item* semi_nl] + +end # ctx + + +CTX: ctx = cons ctx [] +CTX.SP = cons parser<start2> [] +send CTX.SP "a b{c}" + +parse Input: ctx::start1( CTX )[stdin] + +send CTX.SP "{e}f g" + +print( Input ) +print( CTX.SP() '\n' ) + +##### IN ##### +a b c ( d ) e f g ; +##### EXP ##### +A +B +a b c ( d ) e f g ; +a b{c}{ B{d} }{e}f g |