All Packages Class Hierarchy This Package Previous Next Index
Class javaParse.ParseTable
java.lang.Object
|
+----javaParse.ParseTable
- public class ParseTable
- extends Object
-
ParseTable(String[], String[])
-
-
addString(char, char, String)
-
-
addString(String, String, String)
-
-
colIndex(String)
-
-
getColLabels()
-
-
getParseTableAsMatrix()
-
-
getRowLabels()
-
-
hasMultipleEntries()
-
-
rowIndex(String)
-
-
setParseTableMatrix(String[][])
-
used to reset the parse table to the user's entered table
(this is done in case there are conflicts in the table and
the user wants to rearrange the conflicts so that one rule
is used instead of another)
-
stringAt(char, char)
-
-
stringAt(String, String)
-
ParseTable
public ParseTable(String rowLabels[],
String colLabels[])
- Parameters:
- rowLabels - all Strings in this array are valid row indexes
- colLabels - all Strings in this array are valid col indexes
all Strings in rows and cols MUST be completely unique,
no parsing tables share a col or row label
addString
public void addString(String row,
String col,
String addMe)
- Parameters:
- row - the row coord
- col - the col coord
- addMe - any unique String that exists at position Table(row,col)
can even add multiple Strings at one position since
stringAt returns a String of Strings which are separated by spaces
addMe can contain multiple entries already, separated by a space
DOES NOT ADD DUPLICATES!!! -- will check for Dupes
rowIndex
public int rowIndex(String row)
- Parameters:
- returns - array index of where the given string appears in
- the - table
colIndex
public int colIndex(String col)
- Parameters:
- returns - array index of where the given string appears in
- the - table
addString
public void addString(char row,
char col,
String addMe)
- Parameters:
- row - the row coord will be converted to a String for you
- col - the col coord will be converted to a String for you
- addMe - any String that exists at position Table(row,col)
can even add multiple Strings at one position since
stringAt returns a String of Strings which are separated by spaces
DOES NOT ADD DUPLICATES!!! -- will check for Dupes
stringAt
public String stringAt(String row,
String col)
- Parameters:
- row - the row coord
- col - the col coord
- Returns:
- the String at position Table(row,col)
Note: if the String returned == "", then the entry is an ERROR
also, blanks in the String indicate conflicts
stringAt
public String stringAt(char row,
char col)
- Parameters:
- row - the row coord will be converted to a String for you
- col - the col coord will be converted to a String for you
- Returns:
- the String at position Table(row,col)
Note: if the String returned == "", then the entry is an ERROR
also, blanks in the String indicate conflicts
hasMultipleEntries
public boolean hasMultipleEntries()
- Returns:
- returns true if one or more entries in the Table
contains multiple Strings, thus the table has conflicts that
will not allow the user to parse a String
getRowLabels
public String[] getRowLabels()
- Returns:
- returns a reference to the rowLabels that
were originally sent to the constructor since this
class assumes that a call to this function is only for
traversing the table, not changing the labels
This just saves copying an array that will be trashed
once the user has used to move through his table
getColLabels
public String[] getColLabels()
- Returns:
- returns a reference to the colLabels that
were originally sent to the constructor since this
class assumes that a call to this function is only for
traversing the table, not changing the labels
This just saves copying an array that will be trashed
once the user has used to move through his table
getParseTableAsMatrix
public String[][] getParseTableAsMatrix()
- Returns:
- returns a newly allocated double array (matrix)
Given: RowLabels[ S, A, B ] ColLabels[ a, b, c, $ ]
a b c $
S 0 0 0 0 the 0s represent Strings stored in
A 0 0 0 0 the double matrix which is being returned
B 0 0 0 0 such that stringAt(S,a) can now
be referenced as [0,0]
setParseTableMatrix
public void setParseTableMatrix(String matrix[][])
- used to reset the parse table to the user's entered table
(this is done in case there are conflicts in the table and
the user wants to rearrange the conflicts so that one rule
is used instead of another)
All Packages Class Hierarchy This Package Previous Next Index