[antlr-interest] AST generation: EXPRESSION TREE example.
Bharath Sundararaman
bharath at starthis.com
Thu Jun 3 09:05:56 PDT 2004
Hi Tom,
That's pretty much where I'm at, too. I'm creating null placeholders and
using setText() method to bring out a neat AST structure which will be very
readable. Did you try the ASTFrame option to actually view the AST
structure? If you havent tried it already,
----------------------------------------------
ASTFrame frame = new ASTFrame("My AST", ast);
frame.setVisible(true);
----------------------------------------------
Also, I found Ter's lectures on his course site (lecture notes and audio) on
ASTs extremely useful. http://www.cs.usfca.edu/~parrt/course/652/ is the
site.
Hope this helps.
Bharath.
-----Original Message-----
From: Tom Verbeure [mailto:hombre at gmail.com]
Sent: Thursday, June 03, 2004 10:45 AM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] AST generation: EXPRESSION TREE example.
Hi Bharath,
> Thank you very much. Are you generating an abstract syntax tree for
> your grammar, yet? I would like to know what drives your AST
> structure. What do you need it for?
I've only just started working on it and it's going slowly. One
(trivial) thing I didn't realize up front, was that, without any
annotations, the AST tree is simply a list of all the original tokens. I
found it very useful to add
System.out.println(parser.getAST()).toStringList());
to get an idea about what was generated after building the AST.
I add a quite number of non-token nodes to tree to make tree parsing as
simple as possible. Other than that, I can't give you much useful
information. Right now, it's quite an interative process.
Tom
Yahoo! Groups Links
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list