Class Symbol
- java.lang.Object
-
- ru.ispras.microtesk.translator.antlrex.symbols.Symbol
-
public final class Symbol extends java.lang.Object
TheSymbol
class describes a record in a symbol table.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SymbolScope
getInnerScope()
Returns the scope nested into the symbol ornull
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 ornull
if it is not assigned.Where
getWhere()
Returns information on symbol location in source code ornull
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()
-
-
-
Method Detail
-
newReserved
public static Symbol newReserved(java.lang.String name, java.lang.Enum<?> kind, SymbolScope scope)
Creates a new symbol for a reserved keyword. Note: Tag object for the symbol is its name.- Parameters:
name
- Keyword name.kind
- Symbol kind for the keyword.scope
- Scope the symbol will be placed to.- Returns:
- New symbol for a reserved keyword.
- Throws:
java.lang.IllegalArgumentException
- if any of the parameters equalsnull
.
-
newSymbol
public static Symbol newSymbol(java.lang.String name, java.lang.Enum<?> kind, Where where, SymbolScope scope, boolean hasInnerScope)
Creates a new symbol.- Parameters:
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.- Returns:
- New symbol.
- Throws:
java.lang.IllegalArgumentException
- if any of the first four parameters equalsnull
.
-
getName
public java.lang.String getName()
Returns the symbol name.- Returns:
- Symbol name.
-
getKind
public java.lang.Enum<?> getKind()
Returns the symbol kind.- Returns:
- Symbol kind.
-
getWhere
public Where getWhere()
Returns information on symbol location in source code ornull
if the symbol is a reserved keyword.- Returns:
Where
object ornull
for reserved keywords.
-
getOuterScope
public SymbolScope getOuterScope()
Returns the scope where the symbol is defined.- Returns:
- Scope where the symbol is defined.
-
getInnerScope
public SymbolScope getInnerScope()
Returns the scope nested into the symbol ornull
if the symbol has no nested scope.- Returns:
- Nested scope or
null
if the symbol has no nested scope.
-
getTag
public java.lang.Object getTag()
Returns the tag object associated with the symbol ornull
if it is not assigned.- Returns:
- Tag object or
null
if it is not assigned.
-
setTag
public void setTag(java.lang.Object tag)
Links the specified tag object the symbol. Links cannot be reassigned.- Parameters:
tag
- Tag object to be associated with the current symbol.- Throws:
java.lang.IllegalArgumentException
- iftag
isnull
or tag object is already assigned.
-
isReserved
public boolean isReserved()
Checks whether this symbol is a registered keyword.- Returns:
true
if it is a registered keyword orfalse
otherwise.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-