All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class javaParse.GrammarCalculator

java.lang.Object
   |
   +----javaParse.GrammarCalculator

public class GrammarCalculator
extends Object
This class is the powerhouse that does all the calculations. Since each calculation is intimately related to others they are all grouped together in this huge file but complex file. I hope that you will find it well-commented and easy to understand/modify.


Variable Index

 o LL1_MODE
 o LL2_MODE
 o LR1_MODE

Constructor Index

 o GrammarCalculator(GrammarInfo, int)
create a new GrammarCalculator

Method Index

 o getDfaStates()
 o getFirsts()
 o getFirsts2()
 o getFollows()
 o getFollows2()
 o getParseTable()
 o getParseTableAsMatrix()
 o isValid()
 o setDfaStates(Vector)

Variables

 o LL1_MODE
 public static final int LL1_MODE
 o LL2_MODE
 public static final int LL2_MODE
 o LR1_MODE
 public static final int LR1_MODE

Constructors

 o GrammarCalculator
 public GrammarCalculator(GrammarInfo g,
                          int mode)
create a new GrammarCalculator

Parameters:
info - the GrammarInfo that this calculator will use it must have at least one valid Production
mode, - pick between GrammarCalculator.LL1_MODE, GrammarCalculator.LL2_MODE, GrammarCalculator.LR1_MODE, or add your own modes and corresponding functions

Methods

 o isValid
 public boolean isValid()
Returns:
true if no conflicts occur in the table
 o getFirsts
 public String[] getFirsts()
Returns:
FIRST(variable) String[] is in same order as the Variables Vector such that the 0 element is FIRST(start symbol) ... nth is FIRST(nth alpha betized variable). The n+1st entry is FIRST(1st Rhs) and continues through the FIRST(last Rhs). The Grammar's Rhs is never modified
 o getFirsts2
 public String[] getFirsts2()
Returns:
FIRST2(startsymbol) -> FIRST2(alphabetized variables)
 o getFollows
 public String[] getFollows()
Returns:
FOLLOW(start symbol) -> FOLLOW(alphabetized variables)
 o getFollows2
 public String[] getFollows2()
Returns:
FOLLOW2(start symbol) -> FOLLOW2(alphabetized variables) String[]
 o getParseTableAsMatrix
 public String[][] getParseTableAsMatrix()
Returns:
the entries in the ParseTable, without the ability to see the row or col labels. entries can be accessed only by [][] operations
 o getParseTable
 public ParseTable getParseTable()
Returns:
a reference to the ParseTable for the GrammarInfo that was given to GrammarCalculator's constructor
 o getDfaStates
 public Vector getDfaStates()
Returns:
a vector of the states calculated in the Dfa
 o setDfaStates
 public void setDfaStates(Vector v)

All Packages  Class Hierarchy  This Package  Previous  Next  Index