|Examples of parse tree construction in the action part of Yacc input email@example.com (Amit Rekhi) (1999-08-24)|
|From:||"Amit Rekhi" <firstname.lastname@example.org>|
|Date:||24 Aug 1999 12:07:03 -0400|
|Keywords:||yacc, question, comment|
Are there any sample Yacc input specifications on web which use the action
part of grammar rules to construct a parse tree in memory?
I shall be grateful if somene could please pass me the relevant
Thanks in advance,
Amit Rekhi, Software Engineer, A.B. Infosys Private Limited,
B-102, Gulmohar Park, New Delhi - 110049, INDIA.
Tel: +91-11-6512816,6512822,6968976 Fax: +91-11-6518873
Website: http://www.abinfosys.com EMail: email@example.com
[It's quite simple. Each leaf rule creates a leaf node, each non-leaf
rule creates a node pointing to its sub-nodes, and the last one you
create is the root of the parse tree. If you want an AST, you can skip
making new nodes in rules that just describe grouping or precedence. -John]
Return to the
Search the comp.compilers archives again.