summaryrefslogtreecommitdiff
path: root/test/undofrag3.lm
diff options
context:
space:
mode:
Diffstat (limited to 'test/undofrag3.lm')
-rw-r--r--test/undofrag3.lm56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/undofrag3.lm b/test/undofrag3.lm
new file mode 100644
index 0000000..ed96cba
--- /dev/null
+++ b/test/undofrag3.lm
@@ -0,0 +1,56 @@
+##### LM #####
+context undo
+
+ lex
+ ignore /( ' ' | '\t' )+/
+ literal `* `( `) `^ `; `.
+ token NL /'\n'/
+ token id /[a-zA-Z_]+/
+ end
+
+ Out: parser<out>
+
+ def out_item
+ [id]
+ | [`( item* `)]
+
+ def out
+ [out_item*]
+
+ def item
+ [id]
+ {
+ send Out [r1]
+ }
+ | [`( item* `)]
+ {
+ send Out ['(']
+ send Out [r2]
+ send Out [')']
+ }
+
+ def A1 []
+ def A2 []
+
+ def F
+ []
+ {
+ print_xml( Out() )
+ }
+
+ def start
+ [A1 item* F `. `^]
+ | [A2 item* F `. `; NL]
+
+end # undo
+
+cons Undo: undo[]
+Undo.Out = construct parser<undo::out> []
+
+parse Input: undo::start(Undo)[ stdin ]
+print( Input )
+
+##### IN #####
+a . ;
+##### EXP #####
+<undo::out><undo::_repeat_out_item><undo::out_item><undo::id>a</undo::id></undo::out_item></undo::_repeat_out_item></undo::out><undo::out><undo::_repeat_out_item><undo::out_item><undo::id>a</undo::id></undo::out_item></undo::_repeat_out_item></undo::out>a . ;