|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSymbol
public class Symbol
Each Symbol object represents one entry in a SymbolTable.
Field Summary | |
---|---|
private java.util.HashMap |
attributes
|
static int |
CLASSNAME
|
static int |
KEYWORD
|
private java.lang.String |
label
|
static int |
METHOD
|
private int |
type
|
static int |
UNKNOWN_TYPE
|
static int |
VARIABLE
|
Constructor Summary | |
---|---|
Symbol(java.lang.String name,
int t)
Construct a new Symbol with the given name and type. |
Method Summary | |
---|---|
java.lang.Object |
getAttribute(java.lang.String key)
Get an attribute from a Symbol. |
java.lang.String |
getLabel()
Get the label attribute of this object. |
int |
getType()
Get the type of this Symbol. |
void |
putAttribute(java.lang.String key,
java.lang.Object att)
Put an attribute in the HashMap of a Symbol. |
void |
setLabel(java.lang.String name)
Set the label attribute of this object. |
void |
setType(int t)
Set the type of this Symbol. |
java.lang.String |
toString()
Provide the String that describes this Symbol. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private int type
private java.lang.String label
private java.util.HashMap attributes
public static final int UNKNOWN_TYPE
public static final int KEYWORD
public static final int CLASSNAME
public static final int VARIABLE
public static final int METHOD
Constructor Detail |
---|
public Symbol(java.lang.String name, int t)
name
- the label by which the program being compiled
refers to this Symbolt
- the symbol type, an int value. Can be one of the
type values defined by the Symbol class or some other class
like Token.Method Detail |
---|
public java.lang.String getLabel()
public void setLabel(java.lang.String name)
name
- the Symbol labelpublic int getType()
public void setType(int t)
t
- the Symbol typepublic void putAttribute(java.lang.String key, java.lang.Object att)
key
- the name of the attributeatt
- the Object that holds the attribute's valuepublic java.lang.Object getAttribute(java.lang.String key)
key
- the name of the attribute to get
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |