|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectfiniteAutomata.CNFRule
public class CNFRule
Rules for the CNF class.
There are three types of rules allowed in a CNF grammar. Type 0
rules transform a variable to a pair of variables; type 1 rules transform
a variable to a terminal symbol; and type 2 rules transform the start
variable to the empty string (epsilon). The CNFRule class is used to
represent rules of types 0 and 1.
Data Fields: A CNFRule has a "type" (integer code 0 or 1), three integer
variables "var1", "var2", "var3", and a char variable "term" (terminal
symbol).
Type 0 rules are form vn -> vi vj where i and j are non-zero.
In this case, type = 0, var1 = n, var2 = i, var3 = j, and "term" is
irrelevant.
Type 1 rules are form vn -> t. In this case, type = 1,
var1 = n, term = t, and "var2", "var3" are irrelevant.
| Field Summary | |
|---|---|
protected char |
term
right-hand-side terminal symbol (for type 1) |
protected int |
type
indicates type 0 or type 1 |
protected int |
var1
left-hand-side variable |
protected int |
var2
first right-hand-side variable (for type 0) |
protected int |
var3
second right-hand-side variable (for type 0) |
| Constructor Summary | |
|---|---|
CNFRule(CNFRule current)
Copy constructor. |
|
CNFRule(int n,
char t)
2-parameter constructor for type 1 rule, "vn -> t". |
|
CNFRule(int n,
int i,
int j)
3-parameter constructor for type 0 rule, "vn -> vi vj". |
|
| Method Summary | |
|---|---|
boolean |
equals(java.lang.Object other)
Tests whether this CNFRule and the given CNFRule are logically equal. |
static void |
main(java.lang.String[] args)
|
char |
term()
Returns term, the terminal symbol on RHS (or '-' if type 0). |
java.lang.String |
toString()
Returns a pretty String representation of this rule. |
int |
type()
Returns the type. |
int |
var1()
Returns var1, the LHS variable. |
int |
var2()
Returns var2, the first RHS variable (or '-' if type 1). |
int |
var3()
Returns var3, the second RHS variable (or '-' if type 1). |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int type
protected int var1
protected int var2
protected int var3
protected char term
| Constructor Detail |
|---|
public CNFRule(int n,
int i,
int j)
n - LHS variablei - first RHS variablej - second RHS variable
public CNFRule(int n,
char t)
n - LHS variablet - terminal symbolpublic CNFRule(CNFRule current)
current - CNFRule to be copied| Method Detail |
|---|
public int type()
public int var1()
public int var2()
public int var3()
public char term()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - CNFRule to compare with this
public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||