1 31 32 package org.antlr.works.debugger.events; 33 34 public class DBEvent { 35 36 public static final int NO_EVENT = -1; 37 38 public static final int ALL = 0; 39 public static final int NONE = 1; 40 public static final int COMMENCE = 2; 41 public static final int TERMINATE = 3; 42 public static final int LOCATION = 4; 43 public static final int CONSUME_TOKEN = 5; 44 public static final int CONSUME_HIDDEN_TOKEN = 6; 45 public static final int LT = 7; 46 public static final int ENTER_RULE = 8; 47 public static final int EXIT_RULE = 9; 48 public static final int ENTER_SUBRULE = 10; 49 public static final int EXIT_SUBRULE = 11; 50 public static final int ENTER_DECISION = 12; 51 public static final int EXIT_DECISION = 13; 52 public static final int ENTER_ALT = 14; 53 public static final int MARK = 15; 54 public static final int REWIND = 16; 55 public static final int BEGIN_BACKTRACK = 17; 56 public static final int END_BACKTRACK = 18; 57 public static final int BEGIN_RESYNC = 19; 58 public static final int END_RESYNC = 20; 59 public static final int NIL_NODE = 21; 60 public static final int CREATE_NODE = 22; 61 public static final int BECOME_ROOT = 23; 62 public static final int ADD_CHILD = 24; 63 public static final int SET_TOKEN_BOUNDARIES = 25; 64 public static final int RECOGNITION_EXCEPTION = 26; 65 66 private int eventType; 67 68 public DBEvent(int eventType) { 69 this.eventType = eventType; 70 } 71 72 public static String getEventName(int type) { 73 switch(type) { 74 case NO_EVENT: return "-"; 75 case CONSUME_TOKEN: return "Consume"; 76 case CONSUME_HIDDEN_TOKEN: return "Consume hidden"; 77 case ENTER_RULE: return "Enter rule"; 78 case EXIT_RULE: return "Exit rule"; 79 case ENTER_SUBRULE: return "Enter subrule"; 80 case EXIT_SUBRULE: return "Exit subrule"; 81 case ENTER_DECISION: return "Enter decision"; 82 case EXIT_DECISION: return "Exit decision"; 83 case ENTER_ALT: return "Enter alternative"; 84 case LOCATION: return "Location"; 85 case LT: return "LT"; 86 case MARK: return "Mark"; 87 case REWIND: return "Rewind"; 88 case BEGIN_BACKTRACK: return "Begin backtrack"; 89 case END_BACKTRACK: return "End backtrack"; 90 case RECOGNITION_EXCEPTION: return "Recognition exception"; 91 case BEGIN_RESYNC: return "Begin resync"; 92 case END_RESYNC: return "End resync"; 93 case NIL_NODE: return "Nil node"; 94 case CREATE_NODE: return "Create node"; 95 case BECOME_ROOT: return "Become root"; 96 case ADD_CHILD: return "Add child"; 97 case SET_TOKEN_BOUNDARIES: return "Set token boundaries"; 98 case COMMENCE: return "Commence"; 99 case TERMINATE: return "Terminate"; 100 case ALL: return "All"; 101 } 102 return "?"; 103 } 104 105 public int getEventType() { 106 return eventType; 107 } 108 109 public void setEventType(int eventType) { 110 this.eventType = eventType; 111 } 112 113 public String toString() { 114 switch(getEventType()) { 115 case BEGIN_RESYNC: return "Begin resync"; 116 case END_RESYNC: return "End resync"; 117 case COMMENCE: return "Commence"; 118 case TERMINATE: return "Terminate"; 119 } 120 return super.toString(); 121 } 122 123 } 124 | Popular Tags |