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

mzukowski at yci.com mzukowski at yci.com
Mon Oct 28 09:31:07 PST 2002

> in the internal implementation of toStringTree () to StringLKist is
> calle d on the  first child;
> so both give almost similar output.. except the wrapping 
> paranthesis.. 

The only difference between the two should be that tree doesn't print
siblings of the root.  List does.  If your root has no siblings then they
should look identical, I think.
> 2> what is the general rule for placing the caret? is it like the last
> token which has the caret in a given alt, becomes the root?

> 3> i did a small test.. i have a expr grammar, and the ast created by
> it, if i have a list of exprs, but if i want to see the tree generated
> for all of them i have to make the semi colon the root of the tree ;
> if i use toStringTree only the first expression is being shown in lisp
> syntax
> if i use toStringList, all are being displayed
> if i use a dummy token do i have to create the tree manually? like 
>  ## =(DUMMY,#stmnt,##); it does not complain when i run the 
> grammar thu
> antlr if i use dummy token as rot like in (DUMMY^ stmnt SEMI)+ ;
> but i get  runtime exception

Knowing the above, try it again.

 4> is there any corresponding viewer in c++  to see the ast generated
> by parser [like in java using swing components ..]

Not that I'm aware of.



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

More information about the antlr-interest mailing list