Disambiguation In SDF2

Sdf
There are a number of features for disambiguation in SDFII.

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