lex & yacc - cupla questions

Scott Amspoker scott at bbxsda.UUCP
Tue Aug 7 04:17:51 AEST 1990


In article <1990Jul30.202119.2768 at xenitec.on.ca> timk at xenitec.UUCP (Tim Kuehn) writes:
>(Dave Astels) writes:
>>woodward at uicbert.eecs.uic.edu writes:
>>>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.

Sometimes you got to get your fingernails a little dirty.  If you wish to
return tokens from lex that have arbitrarily long lexemes (such as
string litererals or symbol names) you will have to setup your own
dynamic buffering mechanism to retain such values.
-- 
Scott Amspoker
Basis International, Albuquerque, NM
(505) 345-5232
unmvax.cs.unm.edu!bbx!bbxsda!scott



More information about the Comp.lang.c mailing list