help-bison
[Top][All Lists]
Advanced

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

Re: Localized precedence declarations


From: Hans Aberg
Subject: Re: Localized precedence declarations
Date: Tue, 23 Jun 2009 23:29:42 +0200

On 23 Jun 2009, at 20:29, Michiel Helvensteijn wrote:

 The operator precedences in my language are
static. I just need a way to isolate the different groupings of precedence
declarations, so that no shift/reduce conflict is resolved by two
declarations from different groupings.

My method can be worked by hand. This is in fact the safe part; I also made a part where LR is directly modified, and I need to check Knuth's paper on it - on the todo list :-).

Take this example:

%nonassoc IF_THEN_RULE
%nonassoc "else"

%left '+' '-'
%left '*'

It generates the following relative orders:

IF_THEN_RULE < "else"
IF_THEN_RULE < '+'
IF_THEN_RULE < '-'
IF_THEN_RULE < '*'
"else" < '+'
"else" < '-'
"else" < '*'
'+' < '*'
'- < '*'

But I would prefer if only the following relations were understood:

IF_THEN_RULE < "else"
'+' < '*'
'- < '*'

All the others were unintentional, and might silently (and badly) resolve a
shift/reduce conflict that I introduced by accident.

What about adding a '%nonassoc "then"', which resolve the dangling else. The other things should follow.

If that does not help, I can send you my paper (and also if you just want it :-)).

  Hans






reply via email to

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