[antlr-interest] Error in CodeGenTreeWalker

Terence Parr parrt at cs.usfca.edu
Thu Dec 14 13:49:49 PST 2006


hi.  For now, use

BRACK : ('{'|'}') ;
ELSE : . ;
On Dec 14, 2006, at 12:01 PM, Jose San Leandro wrote:

> Hi,
>
> I'm working on a grammar which filters an input with lexical  
> filters and
> modifies some stuff.
>
> I've declared a lexer rule like this:
>
> fragment
> ANYTHING_BUT_BRACKET
>     :   c=~('{'|'}')   {append((char) c);}
>    ;
>
> When executing ANTLR, it fails with the following message:
>
> error(100): AntLangInner.g:0:0: syntax error: codegen: <AST>:0:0:  
> unexpected
> end of subtree
> error(10):  internal error: AntLangInner.g :  
> java.lang.ClassCastException
> org.antlr.codegen.CodeGenTreeWalker.alternative 
> (CodeGenTreeWalker.java:1135)
> org.antlr.codegen.CodeGenTreeWalker.block(CodeGenTreeWalker.java:1000)
> org.antlr.codegen.CodeGenTreeWalker.ebnf(CodeGenTreeWalker.java:2397)
> org.antlr.codegen.CodeGenTreeWalker.element(CodeGenTreeWalker.java: 
> 1856)
>
> I don't know if that is expected or not. What the rule tries to do  
> is to match
> and leave untouched anything but opening or closing brackets. Is  
> there a
> better way to do it?
>
> Thank you in advance,
> Jose.



More information about the antlr-interest mailing list