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: Hans Aberg
Subject: Re: Need help to translate pseudo language in C
Date: Sun, 16 Jan 2005 01:03:12 +0100
User-agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.6

At 22:06 +0000 2005/01/13, Fabien Oimdu 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.

Your original post only mentions the type problem. Use %type and %token for
that (see the Bison manual, Appendix , "Bison Symbols".)

As for the output problem, it is as others have mentioned, that Flex merely
provides a pointer to a buffer, where the strings has temporarily been
'\0'-terminated. At the next call, the buffer gets restored, or it may even
change altogether. So if a rule looking more that one token string, they
must be copied, typically in the lexer. Then, under C, one has to figure out
how to do the cleanup as well. Perhaps the (experimental, undocumented
%destructor) it is of some help to do the C-cleanup during parsing errors.

  Hans Aberg






reply via email to

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