Class Navigate.LocalReferenceNormalizer
- Enclosing class:
- Navigate
It does remove only syntactic sugar, namely an abbreviated way of writing for a compound identifier. Any non-compound reference text (= written without any dot) appearing in the expression of a definition is searched for in the local defs of this definition, and then in the local siblings of this definition.
(This is the same strategy when resolving relative module names.)
So the following transformation applies:
def b = ___ def b = ___ def a = ___ b ___ def a = ___ a.b ___ with local tags b = _ c _ d =====> with local tags b = ___ a.b.c _ a.d with local tags c = __ d __ with local tags c = __ a.d __ end local end local tags d = _ d _ tags d = _ a.d _ end local end localNo nesting is supported: only simple identifiers are compared with the names of the local definitions on the same level. So NO replacement happens for "b.c" in
def a = ___ b.c ___ with local tags b = ___ ____ with local tags c = ___ b ___Nor is there any replacement in the last argument of an explicit substitution expression, because this means an identifier as a textual component, not a reference to a definition:
def a = ___ (@c)^(x/b) ___ with local tags b = ___ b ___This normalization must be done before any substitution is applied, because these operate on normalized but unresolved identifiers, simply replacing text. Therefore the textual representation of all references must be normalized, independently from the (later) resolution process.
This must be taken into consideration when writing replacement clauses:
def a = ___ b ___ with local tags b = ___ DOES REPLACE: DOES NOT REPLACE: def x = @a ^(z/a.b) def x = @a ^(z/b)
Currently this normalization called once for each loaded uninstantiated Module out of ModuleRegistry.load_toplevel_module_from_stream(..)
-
Field Summary
Modifier and TypeFieldDescriptionprotected @Opt TagsRegExp
The lowest definition to search for locals.protected boolean
Whether there are some local definitions, somewhere in the hierarchy.Fields inherited from class eu.bandm.tools.d2d2.model.MATCH_ONLY_00
_visitor_debug_stream, partial
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Chars Reg Exp do not have local defs.void
Service entry point for normalizing all references in an uninstantiated module.void
Compound ids like "A.b" will not be replaced because they are never entered as keys in a directory of definitions (neither module-wide nor local).void
Do not normalize the x in "a^(b/x)
".void
action
(TagsRegExp x) Apply normalization to the expression value of a Tags Reg Exp and to its local definitions.Methods inherited from class eu.bandm.tools.d2d2.model.SinglePhase
action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, follow_definitions, follow_defInstances, follow_docu, follow_firsts, follow_globalSubsts, follow_imports, follow_itemDocu, follow_localdefs, follow_localSubsts, follow_modules, follow_namespaces, follow_obligates, follow_on, follow_rawModules, follow_text, follow_weakfirsts, follow_xattributes
Methods inherited from class eu.bandm.tools.d2d2.model.MATCH_ONLY_00
_visitor_trace, action, action, action, action, compile, followAll_definitions, followAll_defInstances, followAll_docu, followAll_firsts, followAll_globalSubsts, followAll_imports, followAll_itemDocu, followAll_localdefs, followAll_localSubsts, followAll_modules, followAll_namespaces, followAll_obligates, followAll_on, followAll_rawModules, followAll_text, followAll_weakfirsts, followAll_xattributes, foreignObject, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, nomatch
-
Field Details
-
regexpLocals
The lowest definition to search for locals. -
someLocals
protected boolean someLocalsWhether there are some local definitions, somewhere in the hierarchy.
-
-
Constructor Details
-
LocalReferenceNormalizer
public LocalReferenceNormalizer()
-
-
Method Details
-
action
Service entry point for normalizing all references in an uninstantiated module.- Overrides:
action
in classSinglePhase
-
action
Do not normalize the x in "a^(b/x)
".- Overrides:
action
in classSinglePhase
-
action
Chars Reg Exp do not have local defs.- Overrides:
action
in classSinglePhase
-
action
Apply normalization to the expression value of a Tags Reg Exp and to its local definitions.- Overrides:
action
in classSinglePhase
-
action
Compound ids like "A.b" will not be replaced because they are never entered as keys in a directory of definitions (neither module-wide nor local).Does currently not recognize mixtures of locally meant prefix plus explicit qualification, like
tags a = b.c with local tags b = // ... with local tags c = // ... end local end local
- Overrides:
action
in classSinglePhase
-