1 import lexer.RTS; 2 import lexer.DFA; 3 4 import java.util.*; 5 6 class TestRTS { 7 public static void main(String args[]) throws Exception { 8 RTS r = new RTS(); 9 if (!r.isEmpty()) { 10 throw new Exception ("RTS() error"); 11 } 12 int stateNo = 10; 13 int startState = 0; 14 int finalState = 1; 15 String strAlpha = "abc"; 16 Character symbols[] = { null, 17 null, 18 new Character ('a'), 19 null, 20 new Character ('b'), 21 null, 22 null, 23 null, 24 new Character ('c'), 25 null }; 26 Integer next1[] = { new Integer (2), 27 null, 28 new Integer (3), 29 new Integer (4), 30 new Integer (5), 31 new Integer (1), 32 new Integer (8), 33 new Integer (1), 34 new Integer (9), 35 new Integer (8)}; 36 Integer next2[] = { new Integer (6), 37 null, 38 null, 39 null, 40 null, 41 null, 42 new Integer (7), 43 null, 44 null, 45 new Integer (7)}; 46 r = new RTS(stateNo, startState, finalState, strAlpha, symbols, next1, next2); 47 r.print(); 48 49 HashSet set = new HashSet(); 50 boolean b = r.lambda(0, set); 51 System.out.print("lambda(0): "+set+" return: "+b); 52 53 lexer.DFA d = new lexer.DFA(r); 54 System.out.print("\nDFA: "+d); 55 56 System.out.print("\nacceptsString(\"\"): "+d.acceptsString("")); 57 System.out.print("\nacceptsString(\"ab\"): "+d.acceptsString("ab")); 58 System.out.print("\nacceptsString(\"aa\"): "+d.acceptsString("aa")); 59 System.out.print("\nacceptsString(\"c\"): "+d.acceptsString("c")); 60 System.out.print("\nacceptsString(\"cccccc\"): "+d.acceptsString("cccccc")); 61 } 62 } 63
| Popular Tags
|