[antlr-interest] Mismatched Tree Node and lack of StringTemplate output

Johannes Luber jaluber at gmx.de
Wed Jun 6 14:31:19 PDT 2007


Cameron Palmer wrote:
> I created a rule to appear in my AST that involved an imaginary token:
> 
> dsBody
>     : id COLON INT EOL
>     iStructElements -> ^(ISTRUCT id INT iStructElements)
>     ;
> 
> Where ISTRUCT is defined:
> 
> ISTRUCT :;
> 
> This throws a warning:
> The following token definitions are unreachable: ISTRUCT.
> 
> Should I worry about this?

It means, that from the start rule on there is no rule which references
ISTRUCT. It seems, that ANTLR doesn't discover that ISTRUCT is actually
used. Maybe you should put ISTRUCT into a token command. Then the error
may vanish.

> Second question...
> I am getting This error:
> SDFWalker.g: node from line 0:0 mismatched tree node: DOWN expecting
> VERSION

I believe that your grammar doesn't generate the AST correctly. I'd look
in the AST consuming grammar for VERSION and then in the AST creating
grammar for places, where you forgot to put VERSION in. I didn't use the
AST functionality yet, so this may be off.

Best regards,
Johannes Luber



More information about the antlr-interest mailing list