help-bison
[Top][All Lists]
Advanced

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

Re: How to change default outcome of shift/reduce conflict?


From: Akim Demaille
Subject: Re: How to change default outcome of shift/reduce conflict?
Date: 18 Jan 2002 16:40:58 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)

>>>>> "Hans" == Hans Aberg <address@hidden> writes:

Hans> At 15:10 -0700 2002/01/17, Scott Raney wrote:
>> That's my point: the required lookahead in the case of "number" is
>> 3, not 1.

Hans> All LR(n) grammars, n > 1, can be rewritten as LR(1) (to a
Hans> grammar producing the same language) and even to LR(0) if each
Hans> sentence is followed by an end marker, see Robin Hunter,
Hans> "Compilers", sec. 5.2. And all grammars that can be parsed by a
Hans> predictive parser can be parsed by LR(n) techniques, see Aho et
Hans> al, "Compilers...", sec. 4.7.

Hans> So assuming those conditions, you should have a language
Hans> describable by a LR(1) grammar. Then the question is whether it
Hans> can be cut down to LALR(1), which is what Bison uses.

This is over simplification: your words are right, there is an LR(1)
for that _language_, but usually it is good for recognition, not for
parsing.  In other words, it is often very hard to recover the natural
parse tree for an LR(k) grammar which has been massaged down to LR(1).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]