* objc-parse.y
@ 2002-03-12 13:13 Cj B
2002-03-12 14:05 ` objc-parse.y Ashish Gupta
0 siblings, 1 reply; 2+ messages in thread
From: Cj B @ 2002-03-12 13:13 UTC (permalink / raw)
To: gcc-help
While trying to do a "make" on a DEC 3000 OSF1 V4.0 I get the following
error:
cd ./objc; bison -o objc-parse.c objc-parse.y
objc-parse.y contains 72 shift/reduce conflicts
expected 66 shift/reduce conflicts
Any one know how to fix this or what it means?
Thanks in advance
Cj B
black@krellinst.org
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: objc-parse.y
2002-03-12 13:13 objc-parse.y Cj B
@ 2002-03-12 14:05 ` Ashish Gupta
0 siblings, 0 replies; 2+ messages in thread
From: Ashish Gupta @ 2002-03-12 14:05 UTC (permalink / raw)
To: Cj B; +Cc: gcc-help
Cj B wrote:
> While trying to do a "make" on a DEC 3000 OSF1 V4.0 I get the following
> error:
>
> cd ./objc; bison -o objc-parse.c objc-parse.y
> objc-parse.y contains 72 shift/reduce conflicts
> expected 66 shift/reduce conflicts
>
> Any one know how to fix this or what it means?
>
> Thanks in advance
>
> Cj B
> black@krellinst.org
bison is a LALR(1) parser. What objc-parse.y contains ( I persume ) is a
Context Free Grammar represented in BNF (Backus Naur Form) this type of
representation allows .. Bison basically is used to generate a C program
which will parse the semantics of the BNF. here I am quoting what is
present in the bison maual. hope it makes things clearer :-
Suppose we are parsing a language which has if-then and if-then-else
statements, with a pair of rules like this:
if_stmt:
IF expr THEN stmt
| IF expr THEN stmt ELSE stmt
;
Here we assume that `IF', `THEN' and `ELSE' are terminal symbols for
specific keyword tokens.
When the `ELSE' token is read and becomes the look-ahead token, the
contents of the stack (assuming the input is valid) are just right for
reduction by the first rule. But it is also legitimate to shift the
`ELSE', because that would lead to eventual reduction by the second
rule.
This situation, where either a shift or a reduction would be valid,
is called a "shift/reduce conflict". Bison is designed to resolve
these conflicts by choosing to shift, unless otherwise directed by
operator precedence declarations.
** Back to earth here ***
So if there are 2 rules which are both doing the same thing ( or at least
bison is not able to differentiate between the rules. It raises a conflict
If there are 2 possible shifts ( stack push ) for a particular rule it is
a shift conflict similarly if there are 2 reduces ( stack pop ) this is a
reduce conflict. Use Bison with the --verbose option it may help to locate
the conflicting rules The only way i know is to see the conflicts and fix
the grammar rules in the input file to bison.
Hope this helps
Regards,
Ashish Gupta
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-03-12 22:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-12 13:13 objc-parse.y Cj B
2002-03-12 14:05 ` objc-parse.y Ashish Gupta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).