An environment that maps a NameElement' to the scope in which it is bound.
This can be used to model scoping during parsing.
(This class is similar to Burak's ECOOP paper on pattern matching, except that we use
=='
instead of eq', thus types can't be unified in general)
TODO: more documentation
A BoundElement' is bound in a certain scope
scope', which keeps track of the actual element that
el' stands for.
A
BoundElement' is represented textually by its bound element, followed by its scope's id'.
For example:
x@1' represents the variable x' that is bound in the scope with
id' 1'.
The base class for elements of the abstract syntax tree.
The base class for elements in the AST that represent names {@see Binders}.
Returns a given result, but executes the supplied closure before returning.
A Scope' keeps track of one or more syntactic elements that represent bound names.
The elements it contains share the same scope and must all be distinct (wrt. ==)
A
NameElement' n' in the AST that is conceptually bound by a
Scope' s', is replaced by a
BoundElement(n, s)'.
A variable that escaped its scope (i.
Represents an element with variables that are bound in a certain scope.
If a list of UnderBinder's all have the same scope, they can be turned in to an UnderBinder
containing a list of the elements in the original
UnderBinder'.
If a list of UnderBinder's all have the same scope, they can be turned in to an UnderBinder
containing a list of the elements in the original
UnderBinder'.
The name sequence' comes from the fact that this method's type is equal to the type of monadic sequence.
This component provides functionality for enforcing variable binding during parse-time.
When parsing simple languages, like Featherweight Scala, these parser combinators will fully enforce the binding discipline. When names are allowed to be left unqualified, these mechanisms would have to be complemented by an extra phase that resolves names that couldn't be resolved using the naive binding rules. (Maybe some machinery to model
implicit' binders (e.g.,
this' and imported qualifiers) and selection on a binder will suffice?)