1 22 23 package org.javacc.parser; 24 25 import java.util.*; 26 27 31 32 public class RSequence extends RegularExpression { 33 34 38 public java.util.Vector units = new java.util.Vector (); 39 40 public Nfa GenerateNfa(boolean ignoreCase) 41 { 42 if (units.size() == 1) 43 return ((RegularExpression)units.elementAt(0)).GenerateNfa(ignoreCase); 44 45 Nfa retVal = new Nfa(); 46 NfaState startState = retVal.start; 47 NfaState finalState = retVal.end; 48 Nfa temp1; 49 Nfa temp2 = null; 50 51 RegularExpression curRE; 52 53 curRE = (RegularExpression)units.elementAt(0); 54 temp1 = curRE.GenerateNfa(ignoreCase); 55 startState.AddMove(temp1.start); 56 57 for (int i = 1; i < units.size(); i++) 58 { 59 curRE = (RegularExpression)units.elementAt(i); 60 61 temp2 = curRE.GenerateNfa(ignoreCase); 62 temp1.end.AddMove(temp2.start); 63 temp1 = temp2; 64 } 65 66 temp2.end.AddMove(finalState); 67 68 return retVal; 69 } 70 71 RSequence() 72 { 73 } 74 75 RSequence(Vector seq) 76 { 77 ordinal = Integer.MAX_VALUE; 78 units = seq; 79 } 80 } 81 | Popular Tags |