public final class Symbol
extends java.lang.Object
Symbol
class describes a record in a symbol table.Modifier and Type | Method and Description |
---|---|
SymbolScope |
getInnerScope()
Returns the scope nested into the symbol or
null if
the symbol has no nested scope. |
java.lang.Enum<?> |
getKind()
Returns the symbol kind.
|
java.lang.String |
getName()
Returns the symbol name.
|
SymbolScope |
getOuterScope()
Returns the scope where the symbol is defined.
|
java.lang.Object |
getTag()
Returns the tag object associated with the symbol or
null if
it is not assigned. |
Where |
getWhere()
Returns information on symbol location in source code or
null
if the symbol is a reserved keyword. |
boolean |
isReserved()
Checks whether this symbol is a registered keyword.
|
static Symbol |
newReserved(java.lang.String name,
java.lang.Enum<?> kind,
SymbolScope scope)
Creates a new symbol for a reserved keyword.
|
static Symbol |
newSymbol(java.lang.String name,
java.lang.Enum<?> kind,
Where where,
SymbolScope scope,
boolean hasInnerScope)
Creates a new symbol.
|
void |
setTag(java.lang.Object tag)
Links the specified tag object the symbol.
|
java.lang.String |
toString() |
public static Symbol newReserved(java.lang.String name, java.lang.Enum<?> kind, SymbolScope scope)
name
- Keyword name.kind
- Symbol kind for the keyword.scope
- Scope the symbol will be placed to.java.lang.IllegalArgumentException
- if any of the parameters equals null
.public static Symbol newSymbol(java.lang.String name, java.lang.Enum<?> kind, Where where, SymbolScope scope, boolean hasInnerScope)
name
- Symbol name.kind
- Symbol kind.where
- Location of the symbol in the source code.scope
- Scope the symbol will be placed to.hasInnerScope
- Specifies whether the symbol has an inner scope.java.lang.IllegalArgumentException
- if any of the first four parameters
equals null
.public java.lang.String getName()
public java.lang.Enum<?> getKind()
public Where getWhere()
null
if the symbol is a reserved keyword.Where
object or null
for reserved keywords.public SymbolScope getOuterScope()
public SymbolScope getInnerScope()
null
if
the symbol has no nested scope.null
if the symbol has no nested scope.public java.lang.Object getTag()
null
if
it is not assigned.null
if it is not assigned.public void setTag(java.lang.Object tag)
tag
- Tag object to be associated with the current symbol.java.lang.IllegalArgumentException
- if tag
is null
or tag
object is already assigned.public boolean isReserved()
true
if it is a registered keyword or false
otherwise.public java.lang.String toString()
toString
in class java.lang.Object