summaryrefslogtreecommitdiff
path: root/test/superid.lm
diff options
context:
space:
mode:
Diffstat (limited to 'test/superid.lm')
-rw-r--r--test/superid.lm76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/superid.lm b/test/superid.lm
new file mode 100644
index 0000000..eb19020
--- /dev/null
+++ b/test/superid.lm
@@ -0,0 +1,76 @@
+##### LM #####
+context si
+ lex
+ literal `! `a
+
+ token SEMI_NL /';\n'/
+
+ token id /'a'|'b'/
+ {
+ input.push( make_token( trans_id_to input.pull(match_length) ) )
+ }
+
+ token super_id //
+ token foo //
+
+ ignore ws / [ \n\t]+ /
+ end
+
+ trans_id_to: int
+
+ def e1
+ []
+ {
+ print( 'old_id = ' trans_id_to '\n' )
+ trans_id_to = typeid<foo>
+ print( 'new_id = ' trans_id_to '\n' )
+ }
+
+ def item1
+ msg: str
+
+ [ e1 `! `a super_id super_id `a]
+ {
+ lhs.msg = 'this is item1\n'
+ }
+
+ def e2
+ []
+ {
+ print( 'old_id = ' trans_id_to '\n' )
+ trans_id_to = typeid<super_id>
+ print( 'new_id = ' trans_id_to '\n' )
+ }
+
+ def item2
+ msg: str
+
+ [ e2 `! `a super_id super_id `a]
+ {
+ lhs.msg = 'this is item2\n'
+ }
+
+
+ def start
+ [item1 SEMI_NL]
+ | [item2 SEMI_NL]
+ {
+ match lhs [Item2:item2 ';\n']
+ print( Item2.msg )
+ }
+end # si
+
+cons SuperId: si[]
+parse S: si::start(SuperId)[stdin]
+print_xml( S )
+print( '\n' )
+##### IN #####
+!a b b a;
+##### EXP #####
+old_id = NIL
+new_id = 13
+old_id = NIL
+new_id = 12
+this is item2
+<si::start><si::item2><si::e2></si::e2><si::_literal_0001>!</si::_literal_0001><si::_literal_0003>a</si::_literal_0003><si::super_id>b</si::super_id><si::super_id>b</si::super_id><si::_literal_0003>a</si::_literal_0003></si::item2><si::SEMI_NL>;
+</si::SEMI_NL></si::start>