[antlr-interest] Parser question: producing an AST tree?

mzukowski at yci.com mzukowski at yci.com
Wed Oct 23 10:35:53 PDT 2002


What does your tree walker look like?  How do you know it is flat?
Have you printed out a tree with toStringTree() or toStringList()?
Note that in the rule below the second ID will be the root, not the first
ID.

Monty

> -----Original Message-----
> From: Vince Marco [mailto:vmarco at mac.com]
> Sent: Wednesday, October 23, 2002 8:59 AM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Parser question: producing an AST tree?
> 
> 
> Here's a newbie parser question. I'm trying to produce a hierarchical 
> AST tree from a C++ source file.  My lexer works over the 
> 400K codebase, 
> but when I walk the AST I get all the tokens as siblings...ie. a flat 
> tree.  Here is my parser line for a method:
>     cppmethod
>         :    (ID^ COLON COLON (TILDE)? ID^ LPAREN (param (COMMA 
> param)*)? RPAREN cppbody)
>         ;
> 
> I thought that by putting in the carot "^" the remaining 
> tokens would be 
> added as children to the first ID.  My objective was to get 
> the AST tree 
> nested as desired before generating a Walker.  Is this a faulty 
> approach?  All my tokens in the entire file are still 
> siblings (ie. no 
> children).  Any suggestions for what I'm doing wrong?
> 
> Vince
> 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/ 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list