help-bison
[Top][All Lists]
Advanced

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

Re: %left and precedence


From: Bernd Prager
Subject: Re: %left and precedence
Date: Thu, 5 Dec 2002 15:09:38 -0500

----- Original Message -----
From: "Jonathon Duerig" <address@hidden>
Sent: Thursday, December 05, 2002 2:15 AM


> On Wed, 4 Dec 2002, Bernd Prager wrote:
>
> > Well, I solved the problem by rewriting my scanner and handle the
> > space character (' ') now as a token. This works well in the first case.
> > But now I face another puzzling problem that doesn't seem to be
> > related at all.
> > I have also a list construct, delimited by commas.
> > bison eventually recognizes this construct, but not before telling me
> > it would be a sequence as well. Why is that happening?
>
> Disregard my previous suggestion. I have realized the ideal way to
> represent this. Have a static boolean in your yylex() function called
> "LastTokenWasWord" or something. Set it to true whenever a word is
> processed and false whenever some other token is processed.
>
> Now, this token should determine behaviour if whitespace is encountered.
> In the first case (last token was a word), you will condense all
> whitespace into a single character ' ' token which will be returned.
>
> In the second case, all whitespace is ignored, and the next valid
> non-whitespace character can be returned.
>
> This way everything is fixed inside the yylex() function and you don't
> have to worry about subtle shift-reduce conflicts in the parser itself.
>

My scanner eliminates already every unnecessary whitespace.
This is really not the case here .
It seems to be something else.
:-\

-- B.






reply via email to

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