goldengine.java
Class Rule

java.lang.Object
  |
  +--goldengine.java.Rule
All Implemented Interfaces:
SymbolTypeConstants

public class Rule
extends java.lang.Object
implements SymbolTypeConstants

-------------------------------------------------------------------------------------------
Source File: Rule.java
Author: Devin Cook, Matthew Hawkins
Description: A representation of a rule associated with this grammar.
-------------------------------------------------------------------------------------------
Revision List

      Author          Version         Description
      ------          -------         -----------
      MPH             1.0             First Issue
      MPH             1.1             Added the TrimReductions property and required logic

-------------------------------------------------------------------------------------------
IMPORT: NONE
-------------------------------------------------------------------------------------------


Fields inherited from interface goldengine.java.SymbolTypeConstants
symbolTypeCommentEnd, symbolTypeCommentLine, symbolTypeCommentStart, symbolTypeEnd, symbolTypeError, symbolTypeNonterminal, symbolTypeTerminal, symbolTypeWhitespace
 
Constructor Summary
Rule()
          Rule Constructor: This constructor initialises this rule and creates a new SymbolList and the table index.
 
Method Summary
 void addItem(Symbol item)
          addItem This method will add a symbol to the Symbol list.
 boolean containsOneNonTerminal()
          containsOneNonTerminal #ver1.1# This method will check to see if the rule contains a non terminal.
 java.lang.String definition()
          definition This method will return the right hand side of the rule, It does this by concatenating all the Symbols in the Symbol list.
 Symbol getRuleNonTerminal()
          getRuleNonTerminal Will return the Non-Terminal Symbol associated with this Rule.
 int getSymbolCount()
          getSymbolCount Will return how many symbols are contained in this Rule.
 Symbol getSymbols(int index)
          getSymbols Will return the Symbol at the index specified.
 int getTableIndex()
          getTableIndex Will return what index the table index in this Rule is at.
 java.lang.String getText()
          getText This method uses the method name() and definiton() to create a String representing the entirety of this Rule.
 boolean isEqual(Rule secondRule)
          isEqual #ver1.1# This method will check equality of two Rules - this and the one passed in.
 java.lang.String name()
          name Will return a String consisting of the Rules name.
 void setRuleNonTerminal(Symbol nonTerminal)
          setRuleNonTerminal Will setup the Non-Terminal symbol to that passed in.
 void setTableIndex(int index)
          setTableIndex Will set the current table index to that passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rule

public Rule()
Rule Constructor: This constructor initialises this rule and creates a new SymbolList and the table index.
Method Detail

getTableIndex

public int getTableIndex()
getTableIndex Will return what index the table index in this Rule is at.
Returns:
The table index.

getSymbolCount

public int getSymbolCount()
getSymbolCount Will return how many symbols are contained in this Rule.
Returns:
The number of symbols.

getRuleNonTerminal

public Symbol getRuleNonTerminal()
getRuleNonTerminal Will return the Non-Terminal Symbol associated with this Rule.
Returns:
The Non-Terminal of this Rule.

setTableIndex

public void setTableIndex(int index)
setTableIndex Will set the current table index to that passed in.
Parameters:
index - The table index wanted.

setRuleNonTerminal

public void setRuleNonTerminal(Symbol nonTerminal)
setRuleNonTerminal Will setup the Non-Terminal symbol to that passed in.
Parameters:
nonTerminal - The Non-Terminal Symbol.

getSymbols

public Symbol getSymbols(int index)
getSymbols Will return the Symbol at the index specified. It will do this if and only if the index is not less than 0 and greater than the symbol count.
Parameters:
index - The index of the symbol wanted.
Returns:
The symbol at the specified index.

name

public java.lang.String name()
name Will return a String consisting of the Rules name. This is in the format "<'name of non-terminal'>".
Returns:
The String representing this Rule,

definition

public java.lang.String definition()
definition This method will return the right hand side of the rule, It does this by concatenating all the Symbols in the Symbol list.
Returns:
The String representing the definition of this Rule.

addItem

public void addItem(Symbol item)
addItem This method will add a symbol to the Symbol list.
Parameters:
item - The Symbol to add.

getText

public java.lang.String getText()
getText This method uses the method name() and definiton() to create a String representing the entirety of this Rule.
Returns:
The entire Rule in readable format.

containsOneNonTerminal

public boolean containsOneNonTerminal()
containsOneNonTerminal #ver1.1# This method will check to see if the rule contains a non terminal.
Returns:
True if it does contain one non terminal, false if not.

isEqual

public boolean isEqual(Rule secondRule)
isEqual #ver1.1# This method will check equality of two Rules - this and the one passed in.
Parameters:
secondRule - The rule to check against this one.
Returns:
True if it is equal, false if not.