lex/yacc question

John R. Levine johnl at esegue.segue.boston.ma.us
Thu Dec 14 04:11:39 AEST 1989


In article <1989Nov29.180030.15742 at tcsc3b2.tcsc.com> prs at tcsc3b2.tcsc.com (Paul Stath) writes:
>The y.tab.h file is simply a set of #define <token-name> <number> 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 at esegue.segue.boston.ma.us, {ima|lotus|spdcc}!esegue!johnl
"Now, we are all jelly doughnuts."



More information about the Comp.unix.questions mailing list