On Sun, 16 Jun 2013 10:46:09 -0700 (PDT), Fabrice Leal
<
fabrice...@gmail.com> wrote:
>I'm trying to solve a shift/reduce conflict (an occurrence of the "dangling else" situation, I believe) in a toy parser made with cl-yacc.
>
>From some googling, I tried to add
>
> (:precedence ((:left :elseif)
> (:left :else)
> ))
>
>but I must confess I have no formal education in lexing or parsing, so I'm kinda shooting in the dark here.
>
>Could I get some help in this issue?
Playing with precedence won't help. You can't eliminate the
shift/reduce conflict without disallowing chaining of IF "statements"
... which I presume you do want to permit.
Shift/reduce is merely a warning that the grammar is ambiguous - and
minor ambiguity such as posed by "dangling else" isn't a problem in
practice. yacc's default response is to shift the token, which is the
correct behavior to enable chaining. You may be able to silence the
warning if cl-yacc permits doing so [I haven't any experience with
it].
George