Related articles |
---|
if-then-else ambiguity l41484@alfa.ist.utl.pt (Umm) (1997-04-16) |
Re: if-then-else ambiguity dds@flavors.com (Duncan Smith) (1997-04-18) |
From: | Duncan Smith <dds@flavors.com> |
Newsgroups: | comp.compilers |
Date: | 18 Apr 1997 01:33:42 -0400 |
Organization: | Flavors Technology, Inc. |
References: | 97-04-072 |
Keywords: | yacc, parse |
Umm wrote:
>
> Would it be a correct way, of solving a shift reduce problem in
> yacc/bison of the if-then-else by defining a %left precedence (the
> biggest one) to the else?? that way, we are sure (we were already but
> at least there will not be a warning) that in the presence of the
> else, it will be immediately reduced and not shifted, thus making it
> belong to the closest if.
>
> Is this correct??
I think the resolution must be to SHIFT. I believe this is the default
bahavior.
SHIFT leaves IF-THEN-ELSE on the stack which is then reduced.
REDUCE reduces the IF-THEN on the stack, leaving the ELSE as input to
match an Outer IF-THEN.
-Duncan
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.