help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble with yytext


From: David Durham
Subject: Re: Trouble with yytext
Date: Thu, 06 Dec 2001 09:43:59 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.6) Gecko/20011012

Yes, in my uses of flex/bison, I always strdup(yytext) within flex when I'll be needing the text (as in IDENTs) and use that from then on... You just have to rememer to free strdup's returned pointer at some time


Hans Aberg wrote:

At 01:36 -0800 2001/12/06, ROLAND wrote:

I am using FLEX and BISON to parse input given by the
user.
The input-line is picked up by FLEX correctly, since
it gives som printf-statements of yytext.
When yytext is processed by BISON on the other hand,
yytext appears to be an empty string.
Can someone tell me if there is something wrong in my
code?


Flex does not return a string but a pointer to a buffer of a temporarily
'\0' terminated string.

So if you do not save the string in the buffer pointed at, after the next
Flex call, it will not exist anymore (and Flex may change the buffer).

Since you do not explain or give any explanatory code example, it is hard
to guess more than that.

 Hans Aberg



_______________________________________________
Help-bison mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/help-bison







reply via email to

[Prev in Thread] Current Thread [Next in Thread]