[antlr-interest] v3: Do semantic predicates work differently?
Axel Rauschmayer
axel at rauschma.de
Thu Feb 22 05:30:32 PST 2007
Given the following grammar (motivation: templates for a web
application, text in triple brackets is not escaped, all other text
will be escaped):
block returns [ List<String> value = new ArrayList<String>() ] :
( DIRECT_TEXT { $value.add("("+new DirectText
(DirectText.removeBrackets($DIRECT_TEXT.text))+")"); }
| ESCAPED_TEXT { $value.add($ESCAPED_TEXT.text); }
)+;
ESCAPED_TEXT :
( {input.LA(2)!='[' || input.LA(3)!='['}?=> '['
| ~( '[' | '{' | '}' | '\\' )
)+
;
DIRECT_TEXT :
'[[[' (options {greedy=false;} : .)* ']]]'
;
and the input "a[[[b]]]c", I get the following warning:
> line 1:1 required (...)+ loop did not match anything at character '['
Any ideas as to why this does not work?
Thanks,
Axel
--
Axel Rauschmayer
http://www.pst.ifi.lmu.de/~rauschma/
More information about the antlr-interest
mailing list