help-bison
[Top][All Lists]
Advanced

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

Re: Need help to translate pseudo language in C


From: Kelly Leahy
Subject: Re: Need help to translate pseudo language in C
Date: Thu, 13 Jan 2005 15:25:18 -0800 (PST)

--- Fabien Oimdu <address@hidden> wrote:

> Yeah I tried and I have really strange output
> (duplicated strings)
> 
> Humm I forgot to say an important thing : V and E
> are NOT terminal symbols.
> 

You need to be sure you are using strdup if you are
using char* as a data type.  You can't just do

x = yytext

you need to do something like

x = strdup(yytext) 

instead.  Otherwise, you are just setting your pointer
to the buffer location, not a copy of the buffer
contents.

Of course, you need to free this memory eventually
too, if you are worried about that sort of thing.

Also, if V and E are nonterminals, you'll need to be
sure that you are populating $0 appropriately in the
rules for these nonterminals.

Kelly





reply via email to

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