summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/colm.d/balance1.lm33
-rw-r--r--test/colm.d/balance2.lm38
-rw-r--r--test/colm.d/balance3.lm32
3 files changed, 103 insertions, 0 deletions
diff --git a/test/colm.d/balance1.lm b/test/colm.d/balance1.lm
new file mode 100644
index 00000000..e5ec8e6b
--- /dev/null
+++ b/test/colm.d/balance1.lm
@@ -0,0 +1,33 @@
+lex
+ token id /[a-z]+/
+ ignore /[ \t\n]/
+
+ literal `;
+
+ token PLUS /'+'/ {
+ input->pull( match_length )
+
+ parse S: stmt "there is more;"
+ input->push( S )
+ input->push( "; " )
+ }
+end
+
+def stmt
+ [id* `;]
+
+def main
+ [stmt+]
+
+parse M: main [stdin]
+
+print
+ "parsed tree
+ [M]
+ "<-
+##### IN #####
+a b + c d;
+##### EXP #####
+parsed tree
+a b ; there is more; c d;
+<-
diff --git a/test/colm.d/balance2.lm b/test/colm.d/balance2.lm
new file mode 100644
index 00000000..962df3cb
--- /dev/null
+++ b/test/colm.d/balance2.lm
@@ -0,0 +1,38 @@
+lex
+ token id /[a-z]+/
+ ignore WS /[ \t\n]/
+
+ literal `; `! `@
+
+ token PLUS /'+'/ {
+ # input->pull( match_length )
+ input->push_ignore( make_token( typeid<WS>, input->pull(match_length) ) )
+
+ parse S: stmt "there is more;"
+ input->push( S )
+ input->push( "; " )
+ }
+end
+
+def E1 []
+def E2 []
+
+def stmt
+ [id* `;]
+
+def main
+ [E1 stmt+ `!]
+| [E2 stmt+ `@]
+
+parse M: main [stdin]
+
+print
+ "parsed tree
+ [M]
+ "<-
+##### IN #####
+a b + c d; @
+##### EXP #####
+parsed tree
+a b ; there is more;+ c d; @
+<-
diff --git a/test/colm.d/balance3.lm b/test/colm.d/balance3.lm
new file mode 100644
index 00000000..aae049b7
--- /dev/null
+++ b/test/colm.d/balance3.lm
@@ -0,0 +1,32 @@
+lex
+ token id /[a-z]+/
+ ignore /[ \t\n]/
+
+ literal `;
+
+ token PLUS /'+'/ {
+ input->pull( match_length )
+
+ parse M: main "there is more;"
+ input->push( M )
+ input->push( "; " )
+ }
+end
+
+def stmt
+ [id* `;]
+
+def main
+ [stmt+]
+
+parse M: main [stdin]
+
+print
+ "parsed tree
+ [M]
+ "<-
+##### IN #####
+a b + c d; @
+##### EXP #####
+parsed tree
+NIL<-