Class Symbol

java.lang.Object
  |
  +--Symbol

public class Symbol
extends Object

Each Symbol object represents one entry in a SymbolTable.


Field Summary
static int FUNCTION
          Symbol type: function.
static int GLOBAL
          Symbol scope: global.
private  String label
           
static int LOCAL
          Symbol scope: local.
static int PARAMETER
          Symbol scope: parameter.
private  int scope
           
private static String[] symbolScope
           
private static String[] symbolType
           
private  int type
           
static int UNKNOWN_SCOPE
          Symbol scope: unknown.
static int UNKNOWN_TYPE
          Symbol type: unknown.
static int VARIABLE
          Symbol type: variable.
 
Constructor Summary
Symbol()
          Construct a new Symbol with unknown values for all fields.
Symbol(String name, int t, int s)
          Construct a new Symbol.
 
Method Summary
 String getLabel()
          Get the label attribute of this object.
 int getScope()
          Get the scope of this Symbol.
 int getType()
          Get the type of this Symbol.
 void setLabel(String name)
          Set the label attribute of this object.
 void setScope(int t)
          Set the scope of this Symbol.
 void setType(int t)
          Set the type of this Symbol.
 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

type

private int type

scope

private int scope

label

private String label

symbolType

private static String[] symbolType

UNKNOWN_TYPE

public static final int UNKNOWN_TYPE
Symbol type: unknown.

See Also:
Constant Field Values

FUNCTION

public static final int FUNCTION
Symbol type: function.

See Also:
Constant Field Values

VARIABLE

public static final int VARIABLE
Symbol type: variable.

See Also:
Constant Field Values

symbolScope

private static String[] symbolScope

UNKNOWN_SCOPE

public static final int UNKNOWN_SCOPE
Symbol scope: unknown.

See Also:
Constant Field Values

LOCAL

public static final int LOCAL
Symbol scope: local.

See Also:
Constant Field Values

PARAMETER

public static final int PARAMETER
Symbol scope: parameter.

See Also:
Constant Field Values

GLOBAL

public static final int GLOBAL
Symbol scope: global.

See Also:
Constant Field Values
Constructor Detail

Symbol

public Symbol()
Construct a new Symbol with unknown values for all fields.


Symbol

public Symbol(String name,
              int t,
              int s)
Construct a new Symbol.

Parameters:
name - the label by which the program being compiled refers to this Symbol
t - the symbol type, one of the type values defined by the Symbol class.
s - the symbol scope, one of the scope values defined by the Symbol class.
Method Detail

getLabel

public String getLabel()
Get the label attribute of this object.

Returns:
the Symbol label

setLabel

public void setLabel(String name)
Set the label attribute of this object.

Parameters:
name - the Symbol label

getType

public int getType()
Get the type of this Symbol.

Returns:
the Symbol type

setType

public void setType(int t)
Set the type of this Symbol.

Parameters:
t - the Symbol type

getScope

public int getScope()
Get the scope of this Symbol.

Returns:
the Symbol scope

setScope

public void setScope(int t)
Set the scope of this Symbol.

Parameters:
t - the Symbol scope

toString

public String toString()
Provide the String that describes this Symbol.

Overrides:
toString in class Object