KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > antlr > works > debugger > events > DBEvent


1 /*
2
3 [The "BSD licence"]
4 Copyright (c) 2005 Jean Bovet
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
9 are met:
10
11 1. Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
16 3. The name of the author may not be used to endorse or promote products
17 derived from this software without specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 */

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 JavaDoc 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 JavaDoc 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