Re: What's wrong with my grammar definition in sablecc, who can help me?

George Neuner <gneuner2@comcast.net>
Tue, 11 May 2010 12:51:32 -0400

          From comp.compilers

Related articles
What's wrong with my grammar definition in sablecc, who can help me? pointerkarajan@gmail.com (zheng yang) (2010-05-09)
Re: What's wrong with my grammar definition in sablecc, who can help m gneuner2@comcast.net (George Neuner) (2010-05-11)
Re: What's wrong with my grammar definition in sablecc, who can help m pointerkarajan@gmail.com (zheng yang) (2010-05-14)
Re: What's wrong with my grammar definition in sablecc, who can help m gneuner2@comcast.net (George Neuner) (2010-05-15)
| List of all articles for this month |
From: George Neuner <gneuner2@comcast.net>
Newsgroups: comp.compilers
Date: Tue, 11 May 2010 12:51:32 -0400
Organization: A noiseless patient Spider
References: 10-05-050
Keywords: debug
Posted-Date: 12 May 2010 00:56:53 EDT

On Sun, 9 May 2010 19:38:03 -0700 (PDT), zheng yang
<pointerkarajan@gmail.com> wrote:


>When I generate the parer use sablecc with the custom grammar, so many
>reduce/shift conflicts comes up, I have modified it, but the error
>still there, how can fix it, please help me. below is the grammar
>file.


<snip>


Shift/Reduce conflicts are not necessarily errors - constructs such as
nested IF produce them. Shift/Reduce conflicts are merely an
indication of ambiguity in the grammar.


In the following:


    if ( ... )
        if ( ... )
            statement1;
    else
        statement2;


indentation (which the parser ignores) makes it clear that the else is
attached to the outer IF (a reduction of the inner IF), but the ELSE
could equally well be attached to the inner IF (a shift).


The default behavior for (LA)?LR generators when faced with a
Shift/Reduce conflict is to shift so that more context can be
examined.


In any event, we need to see the errors/warnings to help you.


George



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.