public class Rule extends Object
RuleItems. This representation
is used throughout the multiple processes to generate the structure of the syntax
including computing first, follow, lookaheads, states, actions, grammar tables, and
finally parsing tables.
This class defines a whole rule.| Constructor and Description |
|---|
Rule(int rulenum,
int lineNumber,
int precedence,
NonTerminal leftHand)
Construct a rule
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
int |
exactIndexOf(RuleItem item) |
RuleItem |
getItem(int index) |
List<RuleItem> |
getItems() |
NonTerminal |
getLeftHand() |
int |
getLeftHandId()
Convenience method to get the id of the left hand non-terminal
|
int |
getLineNumber() |
int |
getPrecedence() |
int |
getRulenum() |
void |
setLeftHand(NonTerminal leftHand) |
void |
setLineNumber(int lineNumber) |
void |
setPrecedence(int precedence) |
void |
setRulenum(int rulenum) |
String |
toString()
Returns a graphical directed representation of the left hand symbol
and its items.
|
public Rule(int rulenum,
int lineNumber,
int precedence,
NonTerminal leftHand)
rulenum - is the rule idlineNumber - is the line where the rule appears in the
source fileprecedence - is the precedence of the ruleleftHand - is the left hand symbolpublic RuleItem getItem(int index)
index - is the index of the rule itemRuleItem with index indexpublic int getLeftHandId()
public int getRulenum()
public void setRulenum(int rulenum)
rulenum - the rulenum to setpublic int getLineNumber()
public void setLineNumber(int lineNumber)
lineNumber - the lineNumber to setpublic int getPrecedence()
public void setPrecedence(int precedence)
precedence - the precedence to setpublic NonTerminal getLeftHand()
public void setLeftHand(NonTerminal leftHand)
leftHand - the leftHand to setpublic int exactIndexOf(RuleItem item)
public boolean equals(Object obj)
equals in class ObjectObject.equals(java.lang.Object)public String toString()
toString in class ObjectObject.toString()Copyright © 2017. All rights reserved.