There are a number of features for disambiguation in SDF2.

Associativity

Associativity declarations are used to solve ambiguities of an operator with respect to itself. For example, the production

Exp "+" Exp -> Exp {left}

is annotated with the attribute 'left' which entails that addition is left associative with respect to itself, i.e., a + b + c should be read as (a + b) + c.

Priorities

Priorities can be used to solve ambiguities between operators. For example, the priority declaration

Exp "*" Exp -> Exp > Exp "+" Exp -> Exp

declares multiplication to have higher priority than addition.

Reject Productions

Reject productions are used to exclude some phrases from a sort. The standard application is the exclusion of keywords from lexical sorts. For example, the reject production

"if" -> Id {reject}

excludes 'if' as an identifier.

Restrictions

Follow restrictions are used to declare that some sort cannot be followed by some characters. For instance, the restriction

Id -/- [a-z]

declares that phrases of the sort Id cannot be followed by lower case letters.

Other Disambiguation Methods

  • avoid
  • prefer

Revision: r1.3 - 09 Feb 2004 - 13:21 - MartinBravenboer
Sdf > DisambiguationInSDF2
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback