help-bison
[Top][All Lists]
Advanced

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

Re: shift/reduce conflict with unary


From: Derek M Jones
Subject: Re: shift/reduce conflict with unary
Date: Tue, 21 Aug 2007 15:36:06 +0100
User-agent: Thunderbird 2.0.0.0 (Windows/20070326)

cwcaceres,


I take it the shift reduce conflict occurs on the input:

NUMBER PLUS NUMBER potentially-other-tokens

which can be reduced to a single summation expression
or shifted because there may be a following UPLUS

Your problem is that you are trying to do too much in too few rules.

Create some productions for the unary operators and separate ones for
the binary operators.  See how the C standard has done it, for an
example.

Sorry, I don't understand. How would I create separate productions for unary
and binary operators?

I looked at the C++ grammar. It seems somewhat upside down, but rearranging
I think it's a bit similar to what I did which is why I'm still confused.

Don't forget that your parser has to operate with a single token of
look-ahead.  You think it is similar because you are taking a global
view (the two grammars do specify very similar token sequences).

Try to think in terms of a push down automata that has to decide what
to do given its current state and the next token.  In the case of
the C++ grammar there are no shift/reduce decision conflicts (I'm
assuming you copied it correctly).

--
Derek M. Jones                              tel: +44 (0) 1252 520 667
Knowledge Software Ltd                      mailto:address@hidden
Applications Standards Conformance Testing    http://www.knosof.co.uk




reply via email to

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