summaryrefslogtreecommitdiff
path: root/test/colm.d/maxlen.lm
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2019-09-09 10:19:58 -0600
committerAdrian Thurston <thurston@colm.net>2019-09-09 10:19:58 -0600
commitfff52cd5a567ec541cd487b9fee2d89bf9b6f6eb (patch)
tree046a3f0f457343f7c99bf096863daf023a085051 /test/colm.d/maxlen.lm
parent2d8e9c3f5c0417d6237c945c50f92bf8d28b32d5 (diff)
downloadcolm-fff52cd5a567ec541cd487b9fee2d89bf9b6f6eb.tar.gz
base (aapl, colm, ragel) test cases building
Diffstat (limited to 'test/colm.d/maxlen.lm')
-rw-r--r--test/colm.d/maxlen.lm56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/colm.d/maxlen.lm b/test/colm.d/maxlen.lm
new file mode 100644
index 00000000..29dc92d9
--- /dev/null
+++ b/test/colm.d/maxlen.lm
@@ -0,0 +1,56 @@
+
+context maxlen
+
+ #
+ # Regular Definitions
+ #
+ rl rl_ws /[ \t\n\r\v]+/
+ rl rl_id /[a-zA-Z_][a-zA-Z0-9_]*/
+
+ #
+ # Tokens
+ #
+
+ lex
+ ignore /rl_ws/
+ token id /rl_id/
+ end
+
+ num: int
+ allow: int
+
+ def item
+ [id]
+ {
+ num = num + 1
+ toomuch: int = allow+1
+ if num == toomuch {
+ reject
+ }
+ }
+
+ def open
+ []
+ {
+ num = 0
+ }
+
+ def close []
+
+ def restricted_list
+ [open item*]
+
+ def start
+ [restricted_list id*]
+end # maxlen
+
+MaxLen: maxlen = new maxlen()
+MaxLen->allow = 3
+
+parse S: maxlen::start(MaxLen)[stdin]
+print( xml( S ) )
+print('\n')
+##### IN #####
+a b c d e f g
+##### EXP #####
+<maxlen::start><maxlen::restricted_list><maxlen::open></maxlen::open><maxlen::_repeat_item><maxlen::item><maxlen::id>a</maxlen::id></maxlen::item><maxlen::item><maxlen::id>b</maxlen::id></maxlen::item><maxlen::item><maxlen::id>c</maxlen::id></maxlen::item></maxlen::_repeat_item></maxlen::restricted_list><maxlen::_repeat_id><maxlen::id>d</maxlen::id><maxlen::id>e</maxlen::id><maxlen::id>f</maxlen::id><maxlen::id>g</maxlen::id></maxlen::_repeat_id></maxlen::start>