summaryrefslogtreecommitdiff
path: root/test/backtrack2.lm
diff options
context:
space:
mode:
Diffstat (limited to 'test/backtrack2.lm')
-rw-r--r--test/backtrack2.lm29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/backtrack2.lm b/test/backtrack2.lm
new file mode 100644
index 0000000..fa3cdfc
--- /dev/null
+++ b/test/backtrack2.lm
@@ -0,0 +1,29 @@
+##### LM #####
+
+# Token names.
+lex
+ token id /[a-z]+/
+ ignore ws /[ \t\n]+/
+end
+
+token bang1 /'!'/
+token bang2 /'!'/
+
+def one [bang1 id id id]
+
+def two [bang2 id id id id]
+
+def prods
+ [one]
+| [two]
+
+def start
+ [prods]
+
+parse S: start[ stdin ]
+print_xml( match S "!aa bb cc dd" )
+print( '\n' )
+##### IN #####
+!aa bb cc dd
+##### EXP #####
+<start><prods><two><bang2>!</bang2><id>aa</id><id>bb</id><id>cc</id><id>dd</id></two></prods></start>