-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestNfa.java
34 lines (30 loc) · 1.13 KB
/
testNfa.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.*;
public class testNfa{
public static void main(String args[]){
//Create the first node and the nfa structure
NfaNode init = new NfaNode("Initial Node");
NfaStruct nfa = new NfaStruct(init);
NfaNode startNode = nfa.getStart();
System.out.println("Single node NFA");
nfa.printNfa(startNode); //Prints out 'Initial Node: {}' since there are no transitions
System.out.println();
NfaNode temp1 = new NfaNode("second");
NfaNode temp2 = new NfaNode("third");
nfa.addNode(temp1, "a"); //Transition to temp1 on the character a
nfa.addNode(temp2, "b"); //Transition to temp2 on the character b
System.out.println("Three node NFA");
nfa.printNfa(startNode);
System.out.println();
NfaNode transNode = nfa.makeTransition("a");
if(nfa.setCurrent(transNode.getIdentifier())){
System.out.println("Set current");
}
NfaNode temp3 = new NfaNode("fourth");
NfaNode temp4 = new NfaNode("fifth");
nfa.addNode(temp3, "a");
nfa.addNode(temp4, "b");
System.out.println("Test makeTransition");
nfa.printNfa(startNode);
System.out.println();
}
}