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 adonovan@imerge.co.uk (Alan Donovan) (1999-11-23)
Re: Simple yacc translator zalman@netcom11.netcom.com (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

Hello,


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:


*begin
A and B and C
D and E and f
*end
A and B and C
D and E and f


--x---
I would like it to translate to:
A*B*C
D*E*F
(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.


Regards,
Raja
[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.