All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class javaParse.GrammarInfo

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

public class GrammarInfo
extends Object
implements Cloneable
allows users to add Productions as Strings and iterate over them, get the Variables, and get the Terminals.


Constructor Index

 o GrammarInfo()
Allocates a new instance of class GrammarInfo.

Method Index

 o addProduction(String)
 o clone()
Creates a clone of the grammar.
 o currentLeftProd()
Returns the current left side of the production.
 o currentProd()
Returns the current production.
 o currentRightProd()
Returns the current right side of the production.
 o currentVar()
 o firstProd()
Set the class production index to the first production in the grammar.
 o firstVar()
Set the class variable index to the start symbol
 o getNumProds()
 o getNumVars()
 o getRightProds()
 o getStartSymbol()
 o getTerminals()
 o getVariables()
 o hasStartProduction()
 o isGoodGrammarInfo()
 o isTerminal(char)
 o isUnrestricted()
 o isVariable(char)
 o leftProdAt(int)
 o nextProd()
Increment the production to the next production.
 o nextVar()
Increment the variable to the next one, interates in alphabetical order, after starting with the Start Symbol
 o prodsAllAdded()
lets the GrammarInfo organize itself, and sort everything since no more prods can be added once Done is called addProd does not check to see if this was called thus, another call to addProd will mess up sorted order that was previously guaranteed
 o prodsDone()
Indicates if the production index is at the last production.
 o rightProdAt(int)
 o varsDone()

Constructors

 o GrammarInfo
 public GrammarInfo()
Allocates a new instance of class GrammarInfo.

Methods

 o clone
 public Object clone()
Creates a clone of the grammar.

Overrides:
clone in class Object
 o prodsAllAdded
 public void prodsAllAdded()
lets the GrammarInfo organize itself, and sort everything since no more prods can be added once Done is called addProd does not check to see if this was called thus, another call to addProd will mess up sorted order that was previously guaranteed

 o isGoodGrammarInfo
 public boolean isGoodGrammarInfo()
Returns:
s true if all productions produce a good GrammarInfo such that every variable begins its own production and every variable is also on the right hand side of the production Only the start symbol is allowed to appear on one side of Prod
 o addProduction
 public boolean addProduction(String prod)
Parameters:
p - production to be added for exp, "S->aSb"
Returns:
true if it adds valid production to the grammar.
 o firstProd
 public void firstProd()
Set the class production index to the first production in the grammar.

 o firstVar
 public void firstVar()
Set the class variable index to the start symbol

 o nextProd
 public void nextProd()
Increment the production to the next production.

 o nextVar
 public void nextVar()
Increment the variable to the next one, interates in alphabetical order, after starting with the Start Symbol

 o currentLeftProd
 public String currentLeftProd()
Returns the current left side of the production.

 o currentRightProd
 public String currentRightProd()
Returns the current right side of the production.

 o currentProd
 public String currentProd()
Returns the current production.

 o currentVar
 public String currentVar()
Returns:
the current variable
 o prodsDone
 public boolean prodsDone()
Indicates if the production index is at the last production.

 o varsDone
 public boolean varsDone()
Returns:
true if the last variable has already been touched
 o leftProdAt
 public String leftProdAt(int pos)
Parameters:
pos - the index in the String 1 < pos <= TotalNumberOfProductions
Returns:
the left side Production in the Grammar Note: used for LR
 o rightProdAt
 public String rightProdAt(int pos)
Parameters:
pos - the index in the String 1 < pos <=hTotalNumberOfProductions
Returns:
the right side of the production at a certain pos Used for LR
 o getStartSymbol
 public String getStartSymbol()
Returns:
the start symbol for the grammar
 o getNumProds
 public int getNumProds()
Returns:
the number of productions in the grammar
 o getNumVars
 public int getNumVars()
Returns:
the number of different variables in the grammar
 o getVariables
 public String[] getVariables()
Returns:
String[] of Variables such that the first element is the starting variable and the rest are all alphabetized: "A" - "Z" is a variable
 o getRightProds
 public String[] getRightProds()
Returns:
a String[] containing the Rhs of the grammar in the original order
 o getTerminals
 public Vector getTerminals()
Returns:
a sorted Vector of terminals where a terminal is "a"- "z" and other misc terminal chars
 o hasStartProduction
 public boolean hasStartProduction()
Returns:
true if S-> has been added somewhere to the GrammarInfo
 o isUnrestricted
 public boolean isUnrestricted()
Returns:
true if the grammar is unrestricted
 o isTerminal
 public boolean isTerminal(char c)
Returns:
true if c is a Terminal (even if it is not a Terminal in this GrammarInfo)
 o isVariable
 public static boolean isVariable(char c)
Returns:
true if c is a Variable (even of it is not a Variable in this GrammarInfo

All Packages  Class Hierarchy  This Package  Previous  Next  Index