|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.problets.domain.model.implement.SymbolTable
public class SymbolTable
A static class to hold the variable, pointer and function names for the program, available data types for the chosen language, and a list of random constants used in the program template
Field Summary | |
---|---|
static int |
NOT_FOUND_INDEX
Integer index returned if a variable name is not found in the symbol table |
static java.lang.String |
NOTFOUND
String returned if a variable name is not found in the symbol table |
Constructor Summary | |
---|---|
SymbolTable()
|
Method Summary | |
---|---|
static void |
addNameAt(java.lang.String type,
java.lang.String name,
int index)
Adds the name of a new variable/pointer/function to the symbol table at the given index |
static boolean |
exists(java.lang.String type,
java.lang.String name)
Returns whether an object of given type and name already exists in the program |
static int |
getIndex(java.lang.String type,
java.lang.String name)
Returns the index (e.g., 1 in |
static java.lang.String |
getName(java.lang.String token)
Given a token such as |
static java.lang.String |
getName(java.lang.String type,
int index)
Returns the name corresponding to the template index (e.g., 1 in |
static RandomModel |
getRandomValue(int index)
Fetches the random value (RandomModel object) of the given index in the symbol table. |
static RandomModel |
getRandomValue(java.lang.String template,
java.lang.String contextDataType)
Fetches the random value (RandomModel object) corresponding to the template. |
static void |
main(java.lang.String[] args)
|
static void |
print()
Prints all the variable names, pointer names, function names and data types in the symbol table along with the index with which they are referred to in the problem template, e.g., count is |
static void |
reset(java.lang.String template)
Clears the symbol table of all prior names of pointers, variables, and functions; clears all random values from the symbol table and randomizes the data types for the new template. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String NOTFOUND
public static final int NOT_FOUND_INDEX
Constructor Detail |
---|
public SymbolTable()
Method Detail |
---|
public static java.lang.String getName(java.lang.String token)
token
- String token such as public static java.lang.String getName(java.lang.String type, int index)
type
- String with one of the following values: pointer/variable/function/datatypeint
- Integer index of the object whose name is sought (e.g., 1 in public static int getIndex(java.lang.String type, java.lang.String name)
type
- String with one of the following values: variable/pointer/datatype/functionname
- String name of the variable/pointer/datatype/function whose index is sought
public static boolean exists(java.lang.String type, java.lang.String name)
type
- String with one of the following values: variable/pointer/datatype/function (not case-sensitive)name
- String name of the variable/pointer/datatype/function whose existence is of interest (case-sensitive)
public static RandomModel getRandomValue(java.lang.String template, java.lang.String contextDataType)
template
- String template of the random object sought, such as contextDataType
- String representing the desired data type of the random object if it has to be created
public static RandomModel getRandomValue(int index)
index
- Integer index of the desired random object (e.g., 1 as in public static void addNameAt(java.lang.String type, java.lang.String name, int index)
type
- String with a value of pointer, variable, or function (not case-sensitive)name
- String name of the pointer, variable, or function that must be added to the symbol tableindex
- Integer index at which the name of the new pointer, variable, or function must be added to the symbol tablepublic static void reset(java.lang.String template)
template
- String template of the new problem for which the symbol table is re-initializedpublic static void print()
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |