1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
//Symbol Table Class
class Token
{
public:
//representation of token
enum TokenType
{
Function, //token is a function
If, Elif, Else, Switch //token is a branch
Variable, Array, //token is an object
While, DoWhile, For, ForEach, //token is a loop
DataStructure, //token is a structure
Comment //token is a comment
};
//if variable, representation of value
enum ValueType
{
Boolean, //object is of type Boolean
String, //object is of type String
Integer, //object is of type Integer
Float, //object is of type Floating Point Number
Null, //object is of type NULL (ie was not initialized)
NAV //Token is not an object, so is Not A Variable (NAV)
};
SymbolTable(string, TokenType, int, ValueType, string); //Declaration Constructor
//Getters
string GetName(); //Returns Identifier of Token
TokenType GetTokenType(); //Returns representation of Token Type
int GetLine(); //Returns Line Token is found on
ValueType GetValueType(); //Returns Value Type, if object
string GetValue(); //Returns Value, if object
//Setters (returns -1 on failure, 0 on success)
int SetName(string); //Set Name of Token
int SetTokenType(TokenType); //Set representation of Token
int SetLine(int); //Set Line of Token
int SetValue(ValueType); //Set Value Type, if object
int SetValue(string); //Set Value, if object
private:
string Identifier; //Token Name
TokenType Token; //Token Type
int Line; //Line found on
ValueType Value; //Type of value, if object
string ObjectValue; //Value, if object
};
|