[Top][All Lists]

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

Re: Controlling the effects of precedence declarations

From: Hans Aberg
Subject: Re: Controlling the effects of precedence declarations
Date: Thu, 15 May 2003 10:40:22 +0200

At 03:58 +0200 2003/05/15, Frank Heckenbach wrote:
>> Precedence declaration can in fact be
>> expressed as a statement about restrictions of the parse tree generated
>> from the grammar alone. One reference is
>> <http://www.cs.uu.nl/people/visser/ftp/BSVV02.pdf>, and as I could could
>> parse that one, I made another version myself.
>I've read this paper now. Actually, it seems to be quite like what I
>have in mind, in that it's based on GLR and that it allows to
>specify precedence "locally" (rule-based, rather than Bison's
>"global" token-based precedence).

I did not look too carefully at it. From the general point of view,
precedences are used to disambiguate a grammar, and must therefore show up
as restrictions on the parse tree possible. The question is rarely how to
find good descriptions of that transition.

I will have to return to my suggestion later. I did not need it from the
theoretical point of view, but used it only when developing a type of
(multicomponent) operator precedence system I think of implementing.

>Of course, it contains much more, and if this will ever be
>implemented in Bison, I'll probably try it (it might help me in
>other areas, such as my directives).
>In the meantime (whatever this means ...), I think my proposed
>`%no-default-precedence' might be a useful solution for this
>particular aspect.

The other description I quoted from the Dick Grune book "Modern Compiler
Design" only depends on resolving conflicts of shift/reduce pairs. So if
one somehow indicates precedence systems to only apply to disjoint subsets
of grammar productions, then that is implementable. One way might be to
indicate the set applicable rules to each precedence set.

The problem is just to get somebody to write the patch. :-) My guess is
that it is not even very hard: There is a function resolve_sr_conflict() in
Bison file conflicts.c which checks the precedences in order to resolve
shift/reduce conflicts. So somehow, one will restricts those precedence
checks in that code snippet.

  Hans Aberg

reply via email to

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