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

Grammar troubles for the Eiffel Language (cont'd, cont'd)



Hi Etienne, others,

The Eiffel grammar is nearly complete... however I am getting a shift / reduce
conflict, and I can't understand why.

I have included my grammar file.

Please advise.

Cheers,

Dave Makalsky

Error Message:

shift/reduce conflict in state [stack: PClassHeader *] on TInvariant in {
        [ PFeatures = * ] followed by TInvariant (reduce),
        [ PInvariant = * TInvariant PAssertion ] (shift)
}
java.lang.RuntimeException:

shift/reduce conflict in state [stack: PClassHeader *] on TInvariant in {
        [ PFeatures = * ] followed by TInvariant (reduce),
        [ PInvariant = * TInvariant PAssertion ] (shift)
}
        at org.sablecc.sablecc.Grammar.computeLALR(Unknown Source)
        at org.sablecc.sablecc.GenParser.caseStart(Unknown Source)
        at org.sablecc.sablecc.node.Start.apply(Unknown Source)
        at org.sablecc.sablecc.SableCC.processGrammar(Unknown Source)
        at org.sablecc.sablecc.SableCC.processGrammar(Unknown Source)
        at org.sablecc.sablecc.SableCC.main(Unknown Source)


Quoting Etienne Gagnon <etienne.gagnon@uqam.ca>:

> Hi Dave,
> 
> Dave Makalsky wrote:
> > Hi:
> > 
> > I am moving along nicely with my Eiffel grammar, but I hit a small snag.
> > 
> > I have the following definition:
> > 
> > feature_adaptation =
> >   rename?  new_exports? undefine? redefine? select? end
> > 
> > How do I allow the keyword 'end' in the feature_adaptation iff at least one
> of
> > the optional constructs are present?
> 
> I assume feature_adaptation is *used* with a "?" when it apprears 
> somewhere else in the grammar (e.g. feature_adaptation?).
> 
> There are 2 usual ways.  The first is to delay the detection of the 
> error in a post-parsing walk of the AST.
> 
> The second is to write:
> 
> feature_adaptation =
>    rename new_exports? undefine? redefine? select? end |
>    new_exports undefine? redefine? select? end |
>    undefine redefine? select? end |
>    redefine select? end |
>    select end;
> 
> Using SableCC 3, this can be converted back into a nice AST, e.g.
> 
>    rename new_exports? undefine? redefine? select? end
>      {-> New feature_adaptation (rename, new_exports, undefine,
>                                  redefine, select) |
>    new_exports undefine? redefine? select? end
>      {-> New feature_adaptation (null, new_exports, undefine,
>                                  redefine, select) |
>    ...
> 
> I assume the AST does not need to keep the end token around.
> 
> Etienne
> 
> -- 
> Etienne M. Gagnon, Ph.D.             http://www.info.uqam.ca/~egagnon/
> SableVM:                                       http://www.sablevm.org/
> SableCC:                                       http://www.sablecc.org/
> 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Sablecc-user mailing list
> Sablecc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sablecc-user
> 




----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

Attachment: eiffel.grammar
Description: Binary data