1 20 21 package JFlex; 22 23 import java.util.*; 24 25 26 32 public class LexicalStates { 33 34 35 Hashtable states; 36 37 38 Vector inclusive; 39 40 41 int numStates; 42 43 44 47 public LexicalStates() { 48 states = new Hashtable(); 49 inclusive = new Vector(); 50 } 51 52 53 56 public void insert(String name, boolean is_inclusive) { 57 if ( states.containsKey(name) ) return; 58 59 Integer code = new Integer (numStates++); 60 states.put(name, code); 61 62 if (is_inclusive) 63 inclusive.addElement(code); 64 } 65 66 67 71 public Integer getNumber(String name) { 72 return (Integer ) states.get(name); 73 } 74 75 76 79 public int number() { 80 return numStates; 81 } 82 83 84 87 public Enumeration names() { 88 return states.keys(); 89 } 90 91 94 public Enumeration getInclusiveStates() { 95 return inclusive.elements(); 96 } 97 } 98 | Popular Tags |