public static class SymbolTable.Scope
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
void |
addDefinition(java.lang.String symbol,
java.lang.Object value)
Add the specified value to the specified symbol's values in
this scope.
|
void |
define(java.lang.String symbol,
java.lang.Object value)
Set the specified symbol's value to the specified value in this
scope.
|
void |
dump(Printer printer)
Dump the contents of this scope.
|
java.lang.String |
getName()
Get this scope's unqualfied name.
|
SymbolTable.Scope |
getNested(java.lang.String name)
Get the nested scope with the specified unqualified name.
|
SymbolTable.Scope |
getParent()
Get this scope's parent.
|
java.lang.String |
getQualifiedName()
Get this scope's qualified name.
|
boolean |
hasNested()
Determine whether this scope has any nested scopes.
|
boolean |
hasNested(java.lang.String name)
Determine whether this scope has the specified unqualified
nested scope.
|
boolean |
hasSymbols()
Determine whether this scope has any local definitions.
|
boolean |
isDefined(java.lang.String symbol)
Determine whether the specified unqualified symbol is defined
in this scope or any of its ancestors.
|
boolean |
isDefinedLocally(java.lang.String symbol)
Determine whether the specified symbol is defined in this
scope.
|
boolean |
isDefinedMultiply(java.lang.String symbol)
Determine whether the specified symbol is defined multiple
times in this scope or any of its ancestors.
|
boolean |
isMergeable(java.lang.String name)
Determine whether the scope with the specified unqualified name
can be merged into this scope.
|
boolean |
isRoot()
Determine whether this scope is the root scope.
|
java.lang.Object |
lookup(java.lang.String symbol)
Get the value for the specified unqualified symbol.
|
SymbolTable.Scope |
lookupBoundScope(java.lang.String symbol)
Get the scope named by the specified unqualified symbol, which
is nested in the scope defining the symbol.
|
java.lang.Object |
lookupLocally(java.lang.String symbol)
Get the local value for the specified unqualified symbol.
|
SymbolTable.Scope |
lookupScope(java.lang.String symbol)
Get the scope defining the specified unqualified symbol.
|
void |
merge(java.lang.String name)
Merge the nested scope with the specified unqualified name into
this scope.
|
java.util.Iterator<java.lang.String> |
nested()
Get an iterator over the names of all nested scopes.
|
java.lang.String |
qualify(java.lang.String symbol)
Qualify the specified unqualified symbol with this scope's
name.
|
java.util.Iterator<java.lang.String> |
symbols()
Get an iterator over the all locally defined symbols.
|
void |
undefine(java.lang.String symbol)
Undefine the specified unqualified symbol.
|
public java.lang.String getName()
public java.lang.String getQualifiedName()
public boolean isRoot()
true if this scope is the root scope.public SymbolTable.Scope getParent()
null if this
scope does not have a parent (i.e., is the root scope).public boolean hasNested()
true if this scope has any nested scopes.public java.util.Iterator<java.lang.String> nested()
public boolean hasNested(java.lang.String name)
name - The nested scope's unqualified name.true if the corresponding scope exists.public SymbolTable.Scope getNested(java.lang.String name)
name - The nested scope's unqualified name.null if there is
no such scope.public boolean isMergeable(java.lang.String name)
name - The nested scope's unqualified name.true if the scope can be merged.java.lang.IllegalArgumentException - Signals that this scope does
not have a nested scope with the specified name.public void merge(java.lang.String name)
name - The nested scope's unqualified name.java.lang.IllegalArgumentException - Signals that (1) this scope
does not have a nested scope with the specified name, (2) any
of the nested scope's children has the same name as one of
this scope's children, or (3) any of the nested scope's
bindings has the same name as one of this scope's bindings.public boolean hasSymbols()
true if this scope has any local
definitions.public java.util.Iterator<java.lang.String> symbols()
public boolean isDefinedLocally(java.lang.String symbol)
symbol - The unqualified symbol.true if the symbol is defined in this
scope.public boolean isDefined(java.lang.String symbol)
symbol - The unqualified symbol.true if the symbol is defined in this scope
or any of its ancestors.public boolean isDefinedMultiply(java.lang.String symbol)
symbol - The unqualified symbol.true if the symbol is defined multiple
times.public SymbolTable.Scope lookupScope(java.lang.String symbol)
symbol - The unqualified symbol.null if there is
no such scope.public java.lang.Object lookup(java.lang.String symbol)
symbol - The unqualified symbol.null if there is
no definition.public SymbolTable.Scope lookupBoundScope(java.lang.String symbol)
symbol - The unqualified symbol.null if there is no
definition or nested scope with the same name.public java.lang.Object lookupLocally(java.lang.String symbol)
symbol - The unqualified symbol.null if there is
no local definition.public void define(java.lang.String symbol,
java.lang.Object value)
symbol - The unqualified symbol.value - The value.public void addDefinition(java.lang.String symbol,
java.lang.Object value)
symbol - The unqualified symbol.value - The value.public void undefine(java.lang.String symbol)
symbol - The unqualified symbol.public java.lang.String qualify(java.lang.String symbol)
symbol - The unqualified symbol.public void dump(Printer printer)
printer - The printer, which need not be registered with a
visitor.Copyright © 2014. All Rights Reserved.