Simple yacc translator

Raja Kanagala <kanagala@Cadence.COM>
19 Nov 1999 22:35:34 -0500

          From comp.compilers

Related articles
Simple yacc translator kanagala@Cadence.COM (Raja Kanagala) (1999-11-19)
Re: Simple yacc translator (Alan Donovan) (1999-11-23)
Re: Simple yacc translator (Zalman Stern) (1999-11-28)
| List of all articles for this month |

From: Raja Kanagala <kanagala@Cadence.COM>
Newsgroups: comp.compilers
Date: 19 Nov 1999 22:35:34 -0500
Organization: Cadence Design System, Inc.
Keywords: yacc, question


I am trying to write a translator which does certain processing when
enclosed with *begin and *end and follows a different set of rules.
E.g: My source is:

A and B and C
D and E and f
A and B and C
D and E and f

I would like it to translate to:
(A and B and C)
(D and E and f)

How can I set rules for the yacc parser to do a set of actions when
enclosed by "*begin" and "*end". Kind of a state machine.
Any help is very much appreciated.

[Set a flag in the begin and end rules in your lexer or parser, test
it in the action code for the "A and B" rules and do one thing or the
other. -John]

Post a followup to this message

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