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

Phil Ritchie endigitalmind at yahoo.co.uk
Fri Dec 2 06:56:01 PST 2005


--- Bryan Ewbank <ewbank at gmail.com> wrote:

> 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());}
>         ;

This brings me back to a place I've been before
(though I thought you were onto something), it raises
a System.IndexOutOfRangeException - "Index was outside
the bounds of the array." at:
FactoryEntry	entry = heteroList_[nodeTypeIndex];
in ASTFactory.cs so does
     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.
> 




		
___________________________________________________________ 
Yahoo! Model Search 2005 - Find the next catwalk superstars - http://uk.news.yahoo.com/hot/model-search/


More information about the antlr-interest mailing list