lex & yacc: beyond calculator examples

14 Jan 1998 14:48:24 -0500

          From comp.compilers

Related articles
lex & yacc: beyond calculator examples scholine@plnt004.comm.mot.com (1998-01-14)
Re: lex & yacc: beyond calculator examples ralph@inputplus.demon.co.uk (Ralph Corderoy) (1998-01-26)
| List of all articles for this month |

From: scholine@plnt004.comm.mot.com
Newsgroups: comp.compilers
Date: 14 Jan 1998 14:48:24 -0500
Organization: Compilers Central
Keywords: lex, yacc, question

I've written a program using lex and yacc which is structurallysimilar
to the canonical calculator examples found in Kernighan &Pike, the
AT&T SVR4 Support Tools manual, and the Gnu Bisonmanual. This program
is a test driver for another program: itaccepts commands typed in at
the console (or redirected from afile) and generates IPC messages to
drive the program under test.Presently all it does is recognize
commands and parameters whichit immediately uses (in function calls
from the actions in thegrammar) to send messages.I'd like to extend
this driver program to have moreprogramming-language-like constructs
such as branching, so that itcan be programmed to repetitively
generate sequences of messages.The problem is I have no clear idea how
to go about doing that.The several tutorials I've seen for yacc all
stop at the pointwhere they've shown how to build a calculator that
can evaluateimmediate expressions.I'm hoping some reader(s) of this
list can suggest how I shouldproceed. I think I would be satisfied if
I could put labels into my scripts and branch to them conditionally
after evaluating anexpression, since I know from the tutorials how to
make symboltables of variables and how to reference those in
[The FAQ has several books with more extended examples of yacc and lex.
You can guess which one I prefer. -John]


Post a followup to this message

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