Examples of parse tree construction in the action part of Yacc input spec.

"Amit Rekhi" <amitr@abinfosys.com>
24 Aug 1999 12:07:03 -0400

          From comp.compilers

Related articles
Examples of parse tree construction in the action part of Yacc input amitr@abinfosys.com (Amit Rekhi) (1999-08-24)
| List of all articles for this month |
From: "Amit Rekhi" <amitr@abinfosys.com>
Newsgroups: comp.compilers
Date: 24 Aug 1999 12:07:03 -0400
Organization: Compilers Central
Keywords: yacc, question, comment

Hello,


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
sources.


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: amit@abinfosys.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]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.