lex & yacc - cupla questions

Dave Astels 880716a at aucs.uucp
Sat Jul 28 04:50:58 AEST 1990


In article <1990Jul26.175545.959 at uicbert.eecs.uic.edu> woodward at uicbert.eecs.uic.edu writes:
>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.

Check your implementation of MAKE for the rule to go from .y to .o
there should be a macro YACCFLAGS or such.  Add a '-d' to that (in the
default file or maybe your makefile.

>3.)  if i have a yacc construct such as:
> 
>line3	: 	A B C
>		{  yacc action sequence }
>
>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.

return a copy of yytext, not a pointer to it.

-- 
"I liked him better before he died" - McCoy, ST V
===============================================================================
Dave Astels            |  Internet: 880716a at AcadiaU.CA
PO Box 835, Wolfville, |  Bitnet:   880716a at Acadia



More information about the Comp.lang.c mailing list