|AST generation using YACC email@example.com (2000-04-01)|
|Date:||1 Apr 2000 14:18:02 -0500|
I am working on a project for a compiler design class. So far, I have
implemented successfully the lexical analyzer and parser for a subset of
ISO standard Pascal. At present, I am outputting a parse tree
'representation' if you may, to verify that the parser is working as it
should. The next step involves the creation of an abstract syntax tree.
I'm using C++, and hope to be able to reuse, at least partially some of
my existing Binary tree classes from previous projects for the actual
tree itself. But I am unfamiliar with how to interface these with yacc.
And how to use Yacc in the AST construction in the first place. I cannot
find any references, in print or on the web for this sort of thing. Can
anyone point me to a good web reference/examples of AST construction
using yacc (no AST generation tools, please), or perhaps provide me with
a high level idea of what the action code in my yacc parser should look
like to get me started on the AST construction.
[The AST is for most purposes the parse tree without the boring parts.
Adjust your parser so that rules like '(' exp ')' pass through their
subtree rather than generating a new one. -John]
Return to the
Search the comp.compilers archives again.