[antlr-interest] Template Rewrite Rule consumes one more Token than expected
Felix Dorner
felix_do at web.de
Mon Apr 21 06:07:12 PDT 2008
Hi,
I have a problem in a template grammar that's rewriting the tokenstream.
I don't understand why the input:
a * b; \n
returns "where's the semicolon?", i.e. the trailing semicolon is eaten
up too...
Thanks for your help. Felix.
Here's the test grammars:
grammar Test;
options{
output=AST;
ASTLabelType=CommonTree;
}
statement
: expression ';'!
;
expression
: ID '*'^ ID;
ID : 'a'..'z';
WS
: ( ' ' | '\t' | '\r' | '\n' )+ { $channel = HIDDEN; } ;
tree grammar TestTree;
options{
tokenVocab=Test;
output=template;
ASTLabelType=CommonTree;
rewrite=true;
}
statement
: expression;
expression
: ^('*' ID ID)
-> template(text={"where's the semicolon?"}) "<text>"
;
More information about the antlr-interest
mailing list