Name analysis according to scope rules
This module augments the specified processor such that it
produces output that makes the results of name analysis visible.
For each identifier occurrence that has one of the identifier
roles of the name analysis modules a line of the form
m in line 23 bound in line 4 of scope in line 3
is written to the standard output file.
The first line number is that of the identifier occurrence,
the second states where its binding was established by a defining
occurrence, and the third where the scope of the binding
has been created, i.e. usually the begin of the range.
For unbound identifier occurrences a line of the form
m unbound in line 35
is written.
The output is produced in left to right order of the
identifier occurrence, independent of the order in which
the bindings are found. The computations for producing that
output are scheduled after the bindings are computed
at all identifier occurrences, in order to avoid problems
of evaluation order scheduling.
The output of the processors specified in $/Name/Examples
is produced by using this module.
To achieve the effect of this module it is simply instantiated.
No inheritance of any roles is necessary.
The module is instantiated by
$/Name/ShowBinding.gnrc+instance=NAME :inst
The instance parameter must have the same value as that
of the instantiation of the basic name analysis module,
i.e. AlgScope , CScope , or BuScope .
Several instances may be used for testing the bindings
in different name spaces.
Unfortunately, this module is NOT usable if the name analysis module
is instantiated with a referto parameter that modifies the
key attribute name.
The module makes use of the facility to associate a DefTableKey
to scopes: for each
NAMERangeScope a new key, and for each
NAMERangeScopeProp its ScopeKey .
NAMERootScope.NAMEGotEnvKey indicates that all those
keys are associated.
If that facility is also used independent of the ShowBinding
module, the computations of NAMERangeScope.NAMEGotEnvKey
and
NAMERangeScopeProp.NAMEGotPropEnvKey have to be
overridden to avoid interference with the intended computations.
The module associates a property named NAMELine to each
identifier key, and to each key of a scope.
Its value is the line number where the
binding is established. An instance of the NAMESetFirst
module is used for that purpose.
Line number 0 is shown for definitions of identifiers and for
scopes if they are not established by roles of name analysis
modules. That holds in particular for predefined identifiers and
for the root environment.
|