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

Re: Eiffel Grammar shift / reduce errors



Hi Everyone:

My grammar is getting better, but I still have two productions which are giving
me grief

bittype and call

I have commented them out temporarily and the grammar compiles.

Can someone help me understand these errors?

Cheers,

DM


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

> Hi Dave and SableCC list members,
> 
> I am really overloaded, currently.  I can offer quick advices, but 
> writing an Eiffel LALR(1) grammar is an effort that goies beyond the 
> little help I can offer in few minutes of work.  From what I've heard, 
> the designers of Eiffel knowignly left some ambiguities in the Eiffel 
> grammar, and resort to GLR parsers to parse some constructs.  As the 
> grammar is ambiguous, I think a parser can reject a specific program 
> when it exhibits (or "hits") an ambiguity!  I just imagine a first-year 
> programming student getting a "you have written an ambiguous program" 
> compiler error...
> 
> Now, from what I have seen across your link, it seems that various 
> Eiffel compilers take different approaches to dealing with those 
> ambiguities (and I would't be suprised that some Eiffel compilers 
> actually use an LALR(1) parser).  Some issue warnings; some resolve the 
> ambiguity by selecting some interpretation, etc.
> 
> You have to keep in mind what a grammar ambiguity means: it means that 
> there exists at least one input string (e.g. program) for which there 
> exists at least two distinct *and* valid syntax trees (according to the 
> grammar).  In fact, many grammar ambiguities allow for an infinite 
> number of valid syntax trees for a single string.  The problem of having 
> the parser choosing (arbitrarily) one syntax tree (among many), is that 
> the selected syntax tree might differ from the one the programmer had in 
> mind when he wrote the string (or program).
> 
> For you more immediate problem, I would say to try to add back the 
> separators in your grammar.  Currently you consider them as Ignored 
> Tokens which is probably wrong.
> 
> If anyone wants to lend a hand, you are welcome!
> 
> Etienne
> 
> 
> -- 
> Etienne M. Gagnon, Ph.D.             http://www.info.uqam.ca/~egagnon/
> SableVM:                                       http://www.sablevm.org/
> SableCC:                                       http://www.sablecc.org/
> 




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

Attachment: eiffel.grammar
Description: Binary data