1 20 21 package JFlex; 22 23 24 32 final public class Action { 33 34 35 38 String content; 39 40 43 int priority; 44 45 49 private boolean isLookAction; 50 51 52 58 public Action(String content, int priority) { 59 this.content = content.trim(); 60 this.priority = priority; 61 } 62 63 64 71 public Action getHigherPriority(Action other) { 72 if (other == null) return this; 73 74 if (other.priority > this.priority) 76 return this; 77 else 78 return other; 79 } 80 81 82 87 public String toString() { 88 return "Action (priority "+priority+", lookahead "+isLookAction+") :"+Out.NL+content; } 90 91 92 99 public boolean isEquiv(Action a) { 100 return this == a || this.content.equals(a.content); 101 } 102 103 104 109 public int hashCode() { 110 return content.hashCode(); 111 } 112 113 114 124 public boolean equals(Object o) { 125 if (o instanceof Action) 126 return isEquiv((Action) o); 127 else 128 return false; 129 } 130 131 136 public boolean isLookAction() { 137 return isLookAction; 138 } 139 140 145 public void setLookAction(boolean b) { 146 isLookAction = b; 147 } 148 149 } 150 | Popular Tags |