Package eu.bandm.tools.d2d2.base
Class Resolver
java.lang.Object
eu.bandm.tools.d2d2.base.Resolver
Changes an unresolved module into a resolved one.
Tactics are :
Can stop processing after errors encountered.
returns != null iff no error encountered.
All errors are reported into a MessageReceiver, which has to be monitored by the calling level!
Only calling level is currently
Tactics are :
- local identifers have already been expanded (to module level scope) during the "load_uninstantiated" process. (The method {---- link ModuleRegistry#load_toplevel_module_from_stream(java.io.InputStream,String)} already has called {--- link Navigate.LocalReferenceNormalizer()#match(Module)}!!)
- here make first a Co-Rewriters copy of the module and all (recursively) imported modules, in their raw, uninstantiated state.
- Then resolve all D2d.References (via "set_resolved()"), thereby stacking and applying all module-level substitutions.
- Then re-write all expression-level substitutions.
- Normalize the resulting expression: (1) eliminate "#empty" references, (2) eliminate seq/alt/perm with zero or one sub-elements, (3) flatten all nested permutations.
- At last do some (more typechecking) analyses: calc first set and calc character sets. THIS COULD BE DISLOCATED TO ONE LEVEL ABOVE !?
Can stop processing after errors encountered.
returns != null iff no error encountered.
All errors are reported into a MessageReceiver, which has to be monitored by the calling level!
Only calling level is currently
ModuleRegistry
.-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Flatten all insertions which are subject to a *LOCAL* substitution.class
Sets up constants in eachExpression
, which cache structural properties of the syntax for later parsing.protected class
Flatten all insertions which are subject to a *LOCAL* substitution.protected class
Links top-level fragment declarations and all parse particles with the same name.protected class
Here all declaration objects, all items and all imported modules are already rewritten. -
Field Summary
Modifier and TypeFieldDescriptionprotected ModuleRegistry
protected MessageTee<SimpleMessage<XMLDocumentIdentifier>>
protected MessageCounter
-
Constructor Summary
ConstructorDescriptionResolver
(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msgoutput, ModuleRegistry modules) -
Method Summary
Modifier and TypeMethodDescription(package private) Module
copyModule
(ImportItem importingItem, Module mod) Import all modules and apply the replacements given with an "import" directive, whenever this refers to an second import statement IN the imported module.protected void
error
(Location<XMLDocumentIdentifier> loc, String txt) protected void
error
(Location<XMLDocumentIdentifier> loc, String txt, Object... obj) protected void
protected boolean
findLoop
(Location<XMLDocumentIdentifier> loc, Module mod) protected void
hint
(Location<XMLDocumentIdentifier> loc, String txt) static void
liftFirstsToSeq
(Expression exp, Seq ns) All directors from "from" are lifted into the directory maps of "to", to point to the "from"-expression.protected void
(package private) void
Gets an "unresolved" module and resolves all imports.protected void
warning
(Location<XMLDocumentIdentifier> loc, String txt)
-
Field Details
-
msg
-
msgcount
-
modules
-
modulesOpen
-
-
Constructor Details
-
Resolver
public Resolver(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msgoutput, ModuleRegistry modules)
-
-
Method Details
-
error
-
error
-
warning
-
hint
-
log
-
failure
-
resolve
Gets an "unresolved" module and resolves all imports.
For each import item:- loads the raw module,
- apply all substitutions,
- and do this for all imported modules recursively.
- resolve all references
- expand all local substitutions and insertions
- (( perform TYPE CHECKING / SITLL MISSING FIXME ???))
- calculate the values of all character set expressions
- calculate the director map ".firsts" for later parsing.
-
findLoop
-
copyModule
Import all modules and apply the replacements given with an "import" directive, whenever this refers to an second import statement IN the imported module. (A second kind of module-level substs, which operate on references, are executed when resolving those, see below.)
Visiting starts with the (externally requested) top-level module and follows the import statements. "importingItem" is the item which caused the loading of the module "mod" which is the context of "item". "importingItem" is null only for all imports into the top-level module.
item is an import statement in the module imported by the current importingItem. so look in importingItem, whether there is a substitution for the prefix of this importitem, and iff, then replace its target module accordingly. The front-end representation looks like ...module a import B from b ^ (C/D) import C from c end module module b import D from d tags x = ... D:y ... end module
.. which will produce a virtual module b', imported into a, with the contentsmodule b' import D from c ...
In this case "B from b" is the "importingItem", containing "(C/D)" as a replacement, and "D from d" is the "item" to process.
NOTE that there could be a further replacementmodule top import A from a ^ (X/C) import X from x //etc. end module
In this case the item "C from c" in module a must be processed (and replaced by "C from x") BEFORE the descending into "B from b", which will replace "D from d" by "D from x". -
moduleLevelReplacementError
-
liftFirstsToSeq
All directors from "from" are lifted into the directory maps of "to", to point to the "from"-expression.
-