yacc & lex - cupla questions

woodward at uicbert.eecs.uic.edu woodward at uicbert.eecs.uic.edu
Fri Jul 27 03:58:31 AEST 1990


i have been trying to parse a straightforward stream of bytes using the
c-preprocessors lex & yacc.  being a new user of these utilities, i have
a couple of problems for which i'd like to solicit your suggestions:
 
---------------------------------------------------------------------
1.)  how does one redefine the i/o in a yacc/lex piece of code?  i.e.
the code which is generated defaults to stdin and stdout for input and
output, respectively.  i'd like to redefine these defaults w/o having 
to hack on the intermediate c-code, since this is a live production 
project; i'd like to be able to update and modify the program simply by 
saying "make". 

---------------------------------------------------------------------
2.)  how can one get the automagically-defined #defines, which can
normally be created from yacc with the -d flag, to come out when you
use a makefile?  i.e. suppose i have lex.l and yacc.y lex and yacc
source files, respectively, and i have object files defined in my makefile 
called lex.o and yacc.o such that "make" follows default rules to create 
these from the aforementioned source files.   

---------------------------------------------------------------------
3.)  if i have a yacc construct such as:
 
line3	: 	A B C
		{  yacc action sequence }


which indicates that the construct line3 is composed of the 3 tokens
A B and C, in that order ...
 
how can i now assign the values of A, B, and C into local vars of my
choice?  the problem lies in the fact that each of A B and C represent
three calls to lex, and if i pass back a pointer to yytext[] from lex, 
i only retain the value of the last token in the sequence, in this case C, 
when i get to the action sequence in my yacc code.  what if i want to 
be able to select the EXACT ascii tokens for each of A B and C above in 
my yacc code.  how do i do that?


any comments or suggestions would be most heartily appreciated.

jp woodward
univ of ill at chicago 
312-996-0939



More information about the Comp.unix.wizards mailing list