diff options
author | Adrian Thurston <thurston@complang.org> | 2012-05-25 18:52:41 +0000 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2012-05-25 18:52:41 +0000 |
commit | 1d8e5d19f1367e0e53e3079c6cdc762c538482e2 (patch) | |
tree | 1f3e5472f9bc69c562e08ee9216c0738d0f171ec | |
parent | f55cd5218f97e37f95e165086c5243abc2518c49 (diff) | |
download | colm-1d8e5d19f1367e0e53e3079c6cdc762c538482e2.tar.gz |
test the capture-ignore mechanism
-rw-r--r-- | test/ignore3.exp | 2 | ||||
-rw-r--r-- | test/ignore3.in | 3 | ||||
-rw-r--r-- | test/ignore3.lm | 16 |
3 files changed, 16 insertions, 5 deletions
diff --git a/test/ignore3.exp b/test/ignore3.exp index e5d19d3b..8eb7240b 100644 --- a/test/ignore3.exp +++ b/test/ignore3.exp @@ -4,5 +4,7 @@ item: .c . item: .( d ) . innr: .(. d .) . item: .e . +item: .( ) . +innr: .(. .) . item: .f . item: .g. diff --git a/test/ignore3.in b/test/ignore3.in index 803aad41..366294bf 100644 --- a/test/ignore3.in +++ b/test/ignore3.in @@ -1,2 +1 @@ -a b c ( d ) e f g; - +a b c ( d ) e ( ) f g; diff --git a/test/ignore3.lm b/test/ignore3.lm index df3ba687..c224769f 100644 --- a/test/ignore3.lm +++ b/test/ignore3.lm @@ -8,21 +8,31 @@ lex start lex inner { ignore /space+/ - token inner /[a-zA-Z_0-9]+/ + token inner_t /[a-zA-Z_0-9]+/ + + literal '' } +def inner + ['' inner_t*] + def item [id] -| ['(' inner* ')'] +| ['(' inner ')'] def start [item* ';'] parse Start: start( stdin ) +if ( ! Start ) { + print( 'parse error\n' ) + exit( 0 ) +} + for I: item in Start { print( 'item: .' %I '.\n' ) - if match I [ O: '(' Inner: inner* C: ')' ] + if match I [ O: '(' Inner: inner C: ')' ] print( 'innr: .' %O '.' %Inner '.' %C '.\n' ) } |