summaryrefslogtreecommitdiff
path: root/test/lhs1.lm
diff options
context:
space:
mode:
Diffstat (limited to 'test/lhs1.lm')
-rw-r--r--test/lhs1.lm42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/lhs1.lm b/test/lhs1.lm
new file mode 100644
index 0000000..f40297f
--- /dev/null
+++ b/test/lhs1.lm
@@ -0,0 +1,42 @@
+##### LM #####
+
+lex
+ ignore /space+/
+ literal `* `( `) `!
+ token SEMI_NL /';\n'/
+ token id /[a-zA-Z_0-9]+/
+end
+
+def item
+ [id]
+ {
+ lhs = cons item ["( " ^r1 " )"]
+ }
+| [`( item* `)]
+ {
+ lhs = cons item ["( " ^r2 " )"]
+ }
+
+def A
+ [] {
+ print( 'A\n' )
+ }
+
+def B
+ [] {
+ print( 'B\n' )
+ }
+
+def start
+ [A item* `!]
+| [B item* SEMI_NL]
+
+parse Start: start[ stdin ]
+print( Start "\n" )
+##### IN #####
+a b c ( d1 d2 ) e f g ;
+##### EXP #####
+A
+B
+( a )( b )( c )( ( d1 )( d2 ) )( e )( f )( g );
+