[antlr-interest] Tree Rewrite Issue with Negation (~)
Terence Parr
parrt at cs.usfca.edu
Wed Jul 30 11:03:44 PDT 2008
thanks...added bug:
http://www.antlr.org:8888/browse/ANTLR-313
Ter
On Jul 30, 2008, at 10:44 AM, Foust wrote:
> ANTLR Gurus,
>
> There seems to be an ANTLR 3 bug (all versions through 3.1b2) when
> using the token negation operator to match a series of tokens in a
> rule that also has an AST rewrite rule.
>
> Although this works (nonsense):
> x : ':' ( v+=(';'|'}') )* ‘;’ -> ^(':' $v) ;
>
> this expression does not work (single tilde added in order to accept
> all tokens, except those two):
> x : ':' ( v+=~(';'|'}') )* ‘;’ -> ^(':' $v) ;
>
> It works as expected, unless the rewrite rule is added to the end.
> Once a “-> …” is added, the following error is produced:
>
> error(10): internal error: T.g :
> java.lang.IllegalArgumentException: Can't find template
> matchSetTrackAndListLabel.st
>
> It may be fixed by breaking out the negation logic into a separately-
> named rule:
> x : ':' ( v+= configVal )* ‘;’ -> ^(':' $v) ;
> configVal: ~(';'|'}')+;
>
> Is this a known bug?
>
> The options used are:
>
> grammar T;
> options {
> backtrack=true; //
> automatically resolve similar rules (which begin the same way)
> memoize=true; // use
> extra memory to speed up backtracking
> output=AST; //
> generate an abstract syntax tree from matched rules
> ASTLabelType=CommonTree; // class of tree node
> (must be cast from Object, otherwise)
> }
>
> Brent
>
More information about the antlr-interest
mailing list