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: 13 Jan 2002 09:22:14 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)

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

Hans> At 14:49 +0100 2002/01/12, Akim Demaille wrote:
>> | or_expr: | expr {} | | or_expr OR or_expr {}
>> |
>> | ...  | ANSWER expr WITH or_expr
>> 
>> Hans is right: this is the kind of grammar transformation you ought
>> to do if you were using a dumb tool.  But do not do that: you are
>> going to make your grammar much more complex, harder to maintain,

Hans> Who has said anything about grammar transformation?

There's a guy on this list named Hans that suggested to transform the
grammar.  I agree he didn't use the word, but for his information, his
suggestion named `grammar transformation' by people working on grammars.

>> and you will even loose performances.

Hans> What performance loss do you have in your mind?

The size of the automaton.  Using precedence directives is more
efficient than additional rules and nonterminals.  But see the books,
or simply what I already posted several times, I'm not here to give a
lecture.

>> Just as nobody would ever program a expr/term/factor grammar for
>> arithmetics in LR,

Hans> Are you suggesting that that example should be removed from the
Hans> Bison manual?

Of course not, the example of the documentation is correct.  I'm
suggesting that your suggestion is not the best means to help _here_.

>> ...you should avoid the solution above.

Hans> Of, course, the question is why?

Err, are you kidding?  Have you ever implemented the idea you just
suggested?  Do you really enjoy having additional nonterminals,
artificial rules, just to see Bison accept your grammar?  Are you
giving advice on something you don't practice?  Your suggestion is the
_last_ resort, that's why the documentation shows it: sometimes you
_have_ to.

_And_ it produces a less efficient parser, as was written right above.



reply via email to

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