[antlr-interest] Re: Heterogeneous AST - simple calculator parser

Sinan sinan.karasu at boeing.com
Wed Feb 13 12:45:03 PST 2002


koud0002 wrote:
> 
> Thanks for your reply.
> 
> The AST is now constructed correctly.
> However, I am now getting "unexpected end of subtree"
> NoViableAltException from the treewalker.
> The treewalker still does not recognize UNARY_MINUS.
> 
> I would still like to use the custom AST.
> What am I doing wrong? Thanks
> 
> Robert
> 

If you look in the examples directory for 'tinybasic'

You will see a piece of code in Main.java that reads like


		if ( showTree ) {
			((CommonAST)t).setVerboseStringConversion(true, tokenNames);
			ASTFactory factory = new ASTFactory();
			AST r = factory.create(0,"AST ROOT");
			r.setFirstChild(t);
			ASTFrame frame = new ASTFrame("TinyBasic AST", r);
			frame.setVisible(true);
			//System.out.println(t.toStringList());
		}

Where showTree is set by -showtree option.

This will give you the complete Parse Tree.

However to make it work you have to do

find antlr -name "*.class" -exec rm {} \;
javac `find antlr -name "*.java" -print`
jar cvf antlrall.jar `find antlr -name "*.class" -print`

to get everything into the antlrall.jar ( The debug classes )

That is how I debug the TreeWalker....

Sinan

 

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



More information about the antlr-interest mailing list