Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!brutus.cs.uiuc.edu!husc6!spdcc!ima!esegue!johnl From: johnl@esegue.segue.boston.ma.us (John R. Levine) Newsgroups: comp.unix.questions Subject: Re: lex/yacc question Message-ID: <1989Dec13.171139.27383@esegue.segue.boston.ma.us> Date: 13 Dec 89 17:11:39 GMT References: <1530@gwusun.gwu.edu> <1989Nov29.180030.15742@tcsc3b2.tcsc.com> Reply-To: johnl@esegue.segue.boston.ma.us (John R. Levine) Organization: Segue Software, Cambridge MA Lines: 24 In article <1989Nov29.180030.15742@tcsc3b2.tcsc.com> prs@tcsc3b2.tcsc.com (Paul Stath) writes: >The y.tab.h file is simply a set of #define statements >which provide mapping of the token names to integer constants. > >The yacc -d option is the best way to do this! In fact, I sometimes use >yacc for the express purpose of generating a set of #define directives while >developing a program with a a lot of constants. I suppose we should take this as testimony reminding us how flexible all of the Unix tools are. With any C compiler written since about 1978, though, it's a lot easier to write an enumeration type: enum { firstsymbol=256, /* or wherever you want to start */ secondsymbol, /* as many more as you want */ }; This gives you the same effect, avoids extra trips through yacc, and in many cases makes the names available in debuggers. -- John R. Levine, Segue Software, POB 349, Cambridge MA 02238, +1 617 864 9650 johnl@esegue.segue.boston.ma.us, {ima|lotus|spdcc}!esegue!johnl "Now, we are all jelly doughnuts."