[antlr-interest] Switching buildAST to true causes "Invalid AST node type" error.

Bryan Ewbank ewbank at gmail.com
Fri Dec 2 06:00:15 PST 2005


Hi Phil,

I don't know if it will help, but...  I've had trouble with missing "#" in
actions when converting between buildAST=false and buildAST=true.

Try replacing this:

    element
        :       a:INT   {System.Console.WriteLine(a.getText());}
        |       b:ID    {System.Console.WriteLine(b.getText());}
        ;

with this:

    // note the "#" chars in the actions
    element
        :       a:INT   {System.Console.WriteLine(#a.getText());}
        |       b:ID    {System.Console.WriteLine(#b.getText());}
        ;

- Bryan

On 12/1/05, Phil Ritchie <endigitalmind at yahoo.co.uk> wrote:
> The grammar below generates classes that build and run fine if buildAST is
> set to false. As soon as I set it to true (without changing anything else) my
> parser raises an "Invalid AST node type" error. I'm not trying to traverse
> the AST, just build it. Can anyone tell me what I'm doing wrong.


More information about the antlr-interest mailing list