Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!cfctech!teemc!ka3ovk!tcsc3b2!prs From: prs@tcsc3b2.tcsc.com (Paul Stath) Newsgroups: comp.unix.questions Subject: Re: lex/yacc question Message-ID: <1989Nov29.180030.15742@tcsc3b2.tcsc.com> Date: 29 Nov 89 18:00:30 GMT References: <1530@gwusun.gwu.edu> Organization: The Computer Solution Company, Inc. Lines: 29 fc121102@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 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 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@tcsc3b2.tcsc.com | "There was no diety involved,