The current method of expressing priorities limits their modularity and extensibility.

When specifying a priority for a production all of the productions with immediately higher and lower priorities have to be listed. This is a problem if knowledge of these neighbouring productions is not available, independent modules may add arbitrary productions at these priorities.

A possible solution would be to provide some means of saying “assign this production to this exsiting priority”. This could be by using symbolic priority names or by allowing the priority of a new production to be assigned the priority of an existing production.

Assuming that “Existing production” has an already established priority and “New production” has not then possible mechanisms would be to:

Allow the extension of priority groups


context-free priorities
{
Existing production
New production
}

Or allow equality in the definition of priorities


context-free priorities
New production
=
Existing production

Submitted by Bob Davison on 10 January 2013 at 15:58

On 13 January 2013 at 09:42 Sebastian Erdweg commented:

The problem Bob describes already shows up at this simple example:

Base language: numerical literals < addition < multiplication

Extension1 adds subtraction: numerical literals < subtraction < multiplication

Extension2 adds division: addition < division, subtraction < division

In particular, extension2 requires knowledge about the priority of subtraction, which was introduced by extension1.

I like Bob’s proposal. It allows us to modularly extend and reason about priorities:

Extension1: subtraction == addition

Extension2: division == multiplication

Then we can reason: Prio(division) == Prio(multiplication) > Prio(addition) == Prio(subtraction)


On 10 March 2013 at 11:58 Guido Wachsmuth tagged sdf

Log in to post comments