summaryrefslogtreecommitdiff
path: root/test/repeat1.lm
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2017-02-22 15:36:54 +0800
committerAdrian Thurston <thurston@colm.net>2017-02-22 15:36:54 +0800
commitbf4c32ff73537111b7c381f8764cca6fc246b4ba (patch)
tree9bf2c335c51fe9f717330abd9fe173f50448fa5d /test/repeat1.lm
parent389a3c8235858395e9885bddafe1fe7da41f898a (diff)
downloadcolm-bf4c32ff73537111b7c381f8764cca6fc246b4ba.tar.gz
flatteneed test directory
Diffstat (limited to 'test/repeat1.lm')
-rw-r--r--test/repeat1.lm41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/repeat1.lm b/test/repeat1.lm
new file mode 100644
index 00000000..9c907ff6
--- /dev/null
+++ b/test/repeat1.lm
@@ -0,0 +1,41 @@
+lex
+ ignore /space+/
+ literal `* `( `)
+ token id /[a-zA-Z_]+/
+end
+
+def item
+ [id]
+| [`( item* `)]
+
+def start
+ [item*]
+
+parse Input: start[ stdin ]
+
+match Input [ItemList: item*]
+
+for I: item* in repeat( ItemList )
+ print( ^I, '\n' )
+
+for I: item* in rev_repeat( ItemList )
+ print( ^I, '\n' )
+##### IN #####
+a b ( c d ) e ( f g ) h i
+##### EXP #####
+a b ( c d ) e ( f g ) h i
+b ( c d ) e ( f g ) h i
+( c d ) e ( f g ) h i
+e ( f g ) h i
+( f g ) h i
+h i
+i
+
+
+i
+h i
+( f g ) h i
+e ( f g ) h i
+( c d ) e ( f g ) h i
+b ( c d ) e ( f g ) h i
+a b ( c d ) e ( f g ) h i