Skip to content

Name Resolution

kbak edited this page Mar 8, 2012 · 1 revision

TODO: improve the text

Name resolution rules disambiguate clafer names used in constraints. A name is resolved in context of a clafer. Names are first resolved with regard to current instance (I), and later in clafer types (T).

  1. (I) Check if identifier is a special name this or parent. The former indicates clafer in which context the constraint is specified. The latter maps to the parent clafer of the clafer in which the constraint is specified. If the context is a concrete root clafer, so it has no parent, the constraint is not well-formed (an error).
  2. (I) Look up the name in children of the context clafer in breadth-first search manner. Treat inherited clafers as children. If there is a name conflict among children, report an error.
  3. (I) Search in the clafer’s ancestors starting from the clafer and up. For each ancestor, look up the name also in its descendants (BFS).
  4. (T) Search in other top-level definitions.
  5. If the name cannot be resolved or is ambiguous within a single step, the constraint is not well-formed and an error is reported.

For navigations (expressions of the form c1.c2…cn) the name resolution rules are applied to resolve c1. Once it is resolved, subsequent clafers (c2…cn) are resolved by applying only rules (1), (2), and (5).