|flex and bison grouping email@example.com (Archana Deshmukh) (2023-05-18)|
|Re: flex and bison grouping firstname.lastname@example.org (Archana Deshmukh) (2023-05-24)|
|Re: flex and bison grouping email@example.com (gah4) (2023-05-25)|
|Re: flex and bison grouping DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2023-05-27)|
|From:||Hans-Peter Diettrich <DrDiettrich1@netscape.net>|
|Date:||Sat, 27 May 2023 02:08:39 +0200|
|References:||23-05-022 23-05-032 23-05-033|
|Injection-Info:||gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="92898"; mail-complaints-to="firstname.lastname@example.org"|
|Posted-Date:||27 May 2023 12:34:14 EDT|
On 5/26/23 2:08 AM, gah4 wrote:
> On Thursday, May 25, 2023 at 5:49:39 AM UTC-7, Archana Deshmukh wrote:
>> I am able to populate the list for "name" parameter. The type is also of type char*.
>> How, I can differentiate between parameter "char* name" or "char* type" when I populate list.
> One that you have to be careful about with C in general, and I suspect in this case,
> is that you might have a pointer to some buffer that is reused. Saving the pointer
> returned by flex might not help. (I suspect John will tell me if this is wrong.)
> You often need to allocate new space, and make a copy to save.
In a typical compiler strings go into lists of literals and identifiers
(types, variables, functions...). The string has to be stored (copied)
on the first occurence, later occurences mostly become references to the
already existing entry (depending on scope rules).
> [You are right -- you need to make a copy of the yytext string in a
> flex action if you want to keep it. Otherwise it'll be overwritten the
> next time the lexer reads a block of input text. This is a very common
> bug. -John]
Return to the
Search the comp.compilers archives again.