lex/yacc question

Paul Stath prs at tcsc3b2.tcsc.com
Thu Nov 30 05:00:30 AEST 1989


fc121102 at gwusun.gwu.edu (M. J. Lamoureux) writes:


>	I have a assignment I'm working on in which I'm supposed to
>"Develop the list of tokens to be placed in a file 'y.tab.h'"  I have
>read the man page for lex, yacc, flex, and bison.  And looked through
>as much other assorted documentation as I really care to, but I have
>yet to find a word on the format of this file.  Is the only way to find
>out to write the yacc code and use the -d option?

[.sig deleted]

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.  This will allow me to quickly
add or change the constants without worrying about how they are numbered.
I just add a %token <token-name> command to my file.y!  If I REALLY care about
the order, I arrange the token directives.  Nobody says the yacc code has to
do anything usefull.  I usually use a mininal grammer.

(No flames about abusing the tools please!  This works great for me. :-)
-- 
===============================================================================
Paul R. Stath       The Computer Solution Co., Inc.       Voice: 804-794-3491
------------------------------------------------+------------------------------
INTERNET:	prs at tcsc3b2.tcsc.com		| "There was no diety involved,



More information about the Comp.unix.questions mailing list