[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Localized precedence declarations
From: |
Michiel Helvensteijn |
Subject: |
Re: Localized precedence declarations |
Date: |
Tue, 23 Jun 2009 20:29:59 +0200 |
User-agent: |
KMail/1.9.9 |
On Tuesday 23 June 2009, Hans Aberg wrote:
> The problem has not been resolved, and the type of grammar constraint
> precedences I made are not implemented.
>
> One way to implement it is to not resolve the operator precedences in
> the grammar, but in the actions. This is the only way in the case the
> operator precedences are set dynamically. One program that uses (or so
> I remember) this approach is Hugs <http://haskell.org/>.
That is far too drastic a measure. 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.
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.
--
Michiel Helvensteijn
address@hidden