1 | // $ANTLR 2.7.6 (2005-12-22): "constraint.g" -> "ConstraintParser.java"$ |
2 | |
3 | package net.sourceforge.hiveevents; |
4 | |
5 | import java.util.HashMap; |
6 | import java.util.Map; |
7 | |
8 | import net.sourceforge.hiveutils.util.PropertyPathUtils; |
9 | |
10 | import antlr.TokenBuffer; |
11 | import antlr.TokenStreamException; |
12 | import antlr.TokenStreamIOException; |
13 | import antlr.ANTLRException; |
14 | import antlr.LLkParser; |
15 | import antlr.Token; |
16 | import antlr.TokenStream; |
17 | import antlr.RecognitionException; |
18 | import antlr.NoViableAltException; |
19 | import antlr.MismatchedTokenException; |
20 | import antlr.SemanticException; |
21 | import antlr.ParserSharedInputState; |
22 | import antlr.collections.impl.BitSet; |
23 | import antlr.collections.AST; |
24 | import java.util.Hashtable; |
25 | import antlr.ASTFactory; |
26 | import antlr.ASTPair; |
27 | import antlr.collections.impl.ASTArray; |
28 | |
29 | public class ConstraintParser extends antlr.LLkParser implements ConstraintParserTokenTypes |
30 | { |
31 | |
32 | protected ConstraintParser(TokenBuffer tokenBuf, int k) { |
33 | super(tokenBuf,k); |
34 | tokenNames = _tokenNames; |
35 | buildTokenTypeASTClassMap(); |
36 | astFactory = new ASTFactory(getTokenTypeToASTClassMap()); |
37 | } |
38 | |
39 | public ConstraintParser(TokenBuffer tokenBuf) { |
40 | this(tokenBuf,2); |
41 | } |
42 | |
43 | protected ConstraintParser(TokenStream lexer, int k) { |
44 | super(lexer,k); |
45 | tokenNames = _tokenNames; |
46 | buildTokenTypeASTClassMap(); |
47 | astFactory = new ASTFactory(getTokenTypeToASTClassMap()); |
48 | } |
49 | |
50 | public ConstraintParser(TokenStream lexer) { |
51 | this(lexer,2); |
52 | } |
53 | |
54 | public ConstraintParser(ParserSharedInputState state) { |
55 | super(state,2); |
56 | tokenNames = _tokenNames; |
57 | buildTokenTypeASTClassMap(); |
58 | astFactory = new ASTFactory(getTokenTypeToASTClassMap()); |
59 | } |
60 | |
61 | public final void expr() throws RecognitionException, TokenStreamException { |
62 | |
63 | returnAST = null; |
64 | ASTPair currentAST = new ASTPair(); |
65 | AST expr_AST = null; |
66 | |
67 | try { // for error handling |
68 | andexpr(); |
69 | astFactory.addASTChild(currentAST, returnAST); |
70 | { |
71 | _loop3: |
72 | do { |
73 | if ((LA(1)==OR)) { |
74 | AST tmp1_AST = null; |
75 | tmp1_AST = astFactory.create(LT(1)); |
76 | astFactory.makeASTRoot(currentAST, tmp1_AST); |
77 | match(OR); |
78 | andexpr(); |
79 | astFactory.addASTChild(currentAST, returnAST); |
80 | } |
81 | else { |
82 | break _loop3; |
83 | } |
84 | |
85 | } while (true); |
86 | } |
87 | expr_AST = (AST)currentAST.root; |
88 | } |
89 | catch (RecognitionException ex) { |
90 | reportError(ex); |
91 | recover(ex,_tokenSet_0); |
92 | } |
93 | returnAST = expr_AST; |
94 | } |
95 | |
96 | public final void andexpr() throws RecognitionException, TokenStreamException { |
97 | |
98 | returnAST = null; |
99 | ASTPair currentAST = new ASTPair(); |
100 | AST andexpr_AST = null; |
101 | |
102 | try { // for error handling |
103 | boolexpr(); |
104 | astFactory.addASTChild(currentAST, returnAST); |
105 | { |
106 | _loop6: |
107 | do { |
108 | if ((LA(1)==AND)) { |
109 | AST tmp2_AST = null; |
110 | tmp2_AST = astFactory.create(LT(1)); |
111 | astFactory.makeASTRoot(currentAST, tmp2_AST); |
112 | match(AND); |
113 | boolexpr(); |
114 | astFactory.addASTChild(currentAST, returnAST); |
115 | } |
116 | else { |
117 | break _loop6; |
118 | } |
119 | |
120 | } while (true); |
121 | } |
122 | andexpr_AST = (AST)currentAST.root; |
123 | } |
124 | catch (RecognitionException ex) { |
125 | reportError(ex); |
126 | recover(ex,_tokenSet_1); |
127 | } |
128 | returnAST = andexpr_AST; |
129 | } |
130 | |
131 | public final void boolexpr() throws RecognitionException, TokenStreamException { |
132 | |
133 | returnAST = null; |
134 | ASTPair currentAST = new ASTPair(); |
135 | AST boolexpr_AST = null; |
136 | |
137 | try { // for error handling |
138 | switch ( LA(1)) { |
139 | case BOOL_PROPERTY: |
140 | case PROPERTY: |
141 | case NUM_LITERAL: |
142 | case STR_LITERAL: |
143 | { |
144 | compexpr(); |
145 | astFactory.addASTChild(currentAST, returnAST); |
146 | boolexpr_AST = (AST)currentAST.root; |
147 | break; |
148 | } |
149 | case LPAREN: |
150 | { |
151 | match(LPAREN); |
152 | expr(); |
153 | astFactory.addASTChild(currentAST, returnAST); |
154 | match(RPAREN); |
155 | boolexpr_AST = (AST)currentAST.root; |
156 | break; |
157 | } |
158 | default: |
159 | { |
160 | throw new NoViableAltException(LT(1), getFilename()); |
161 | } |
162 | } |
163 | } |
164 | catch (RecognitionException ex) { |
165 | reportError(ex); |
166 | recover(ex,_tokenSet_2); |
167 | } |
168 | returnAST = boolexpr_AST; |
169 | } |
170 | |
171 | public final void compexpr() throws RecognitionException, TokenStreamException { |
172 | |
173 | returnAST = null; |
174 | ASTPair currentAST = new ASTPair(); |
175 | AST compexpr_AST = null; |
176 | |
177 | try { // for error handling |
178 | if (((LA(1) >= PROPERTY && LA(1) <= STR_LITERAL)) && (LA(2)==LT)) { |
179 | genexpr(); |
180 | astFactory.addASTChild(currentAST, returnAST); |
181 | AST tmp5_AST = null; |
182 | tmp5_AST = astFactory.create(LT(1)); |
183 | astFactory.makeASTRoot(currentAST, tmp5_AST); |
184 | match(LT); |
185 | genexpr(); |
186 | astFactory.addASTChild(currentAST, returnAST); |
187 | compexpr_AST = (AST)currentAST.root; |
188 | } |
189 | else if (((LA(1) >= PROPERTY && LA(1) <= STR_LITERAL)) && (LA(2)==LE)) { |
190 | genexpr(); |
191 | astFactory.addASTChild(currentAST, returnAST); |
192 | AST tmp6_AST = null; |
193 | tmp6_AST = astFactory.create(LT(1)); |
194 | astFactory.makeASTRoot(currentAST, tmp6_AST); |
195 | match(LE); |
196 | genexpr(); |
197 | astFactory.addASTChild(currentAST, returnAST); |
198 | compexpr_AST = (AST)currentAST.root; |
199 | } |
200 | else if (((LA(1) >= PROPERTY && LA(1) <= STR_LITERAL)) && (LA(2)==GT)) { |
201 | genexpr(); |
202 | astFactory.addASTChild(currentAST, returnAST); |
203 | AST tmp7_AST = null; |
204 | tmp7_AST = astFactory.create(LT(1)); |
205 | astFactory.makeASTRoot(currentAST, tmp7_AST); |
206 | match(GT); |
207 | genexpr(); |
208 | astFactory.addASTChild(currentAST, returnAST); |
209 | compexpr_AST = (AST)currentAST.root; |
210 | } |
211 | else if (((LA(1) >= PROPERTY && LA(1) <= STR_LITERAL)) && (LA(2)==GE)) { |
212 | genexpr(); |
213 | astFactory.addASTChild(currentAST, returnAST); |
214 | AST tmp8_AST = null; |
215 | tmp8_AST = astFactory.create(LT(1)); |
216 | astFactory.makeASTRoot(currentAST, tmp8_AST); |
217 | match(GE); |
218 | genexpr(); |
219 | astFactory.addASTChild(currentAST, returnAST); |
220 | compexpr_AST = (AST)currentAST.root; |
221 | } |
222 | else if (((LA(1) >= PROPERTY && LA(1) <= STR_LITERAL)) && (LA(2)==EQ)) { |
223 | genexpr(); |
224 | astFactory.addASTChild(currentAST, returnAST); |
225 | AST tmp9_AST = null; |
226 | tmp9_AST = astFactory.create(LT(1)); |
227 | astFactory.makeASTRoot(currentAST, tmp9_AST); |
228 | match(EQ); |
229 | genexpr(); |
230 | astFactory.addASTChild(currentAST, returnAST); |
231 | compexpr_AST = (AST)currentAST.root; |
232 | } |
233 | else if (((LA(1) >= PROPERTY && LA(1) <= STR_LITERAL)) && (LA(2)==NE)) { |
234 | genexpr(); |
235 | astFactory.addASTChild(currentAST, returnAST); |
236 | AST tmp10_AST = null; |
237 | tmp10_AST = astFactory.create(LT(1)); |
238 | astFactory.makeASTRoot(currentAST, tmp10_AST); |
239 | match(NE); |
240 | genexpr(); |
241 | astFactory.addASTChild(currentAST, returnAST); |
242 | compexpr_AST = (AST)currentAST.root; |
243 | } |
244 | else if ((LA(1)==BOOL_PROPERTY)) { |
245 | AST tmp11_AST = null; |
246 | tmp11_AST = astFactory.create(LT(1)); |
247 | astFactory.addASTChild(currentAST, tmp11_AST); |
248 | match(BOOL_PROPERTY); |
249 | compexpr_AST = (AST)currentAST.root; |
250 | } |
251 | else { |
252 | throw new NoViableAltException(LT(1), getFilename()); |
253 | } |
254 | |
255 | } |
256 | catch (RecognitionException ex) { |
257 | reportError(ex); |
258 | recover(ex,_tokenSet_2); |
259 | } |
260 | returnAST = compexpr_AST; |
261 | } |
262 | |
263 | public final void genexpr() throws RecognitionException, TokenStreamException { |
264 | |
265 | returnAST = null; |
266 | ASTPair currentAST = new ASTPair(); |
267 | AST genexpr_AST = null; |
268 | |
269 | try { // for error handling |
270 | switch ( LA(1)) { |
271 | case PROPERTY: |
272 | { |
273 | AST tmp12_AST = null; |
274 | tmp12_AST = astFactory.create(LT(1)); |
275 | astFactory.addASTChild(currentAST, tmp12_AST); |
276 | match(PROPERTY); |
277 | genexpr_AST = (AST)currentAST.root; |
278 | break; |
279 | } |
280 | case NUM_LITERAL: |
281 | { |
282 | AST tmp13_AST = null; |
283 | tmp13_AST = astFactory.create(LT(1)); |
284 | astFactory.addASTChild(currentAST, tmp13_AST); |
285 | match(NUM_LITERAL); |
286 | genexpr_AST = (AST)currentAST.root; |
287 | break; |
288 | } |
289 | case STR_LITERAL: |
290 | { |
291 | AST tmp14_AST = null; |
292 | tmp14_AST = astFactory.create(LT(1)); |
293 | astFactory.addASTChild(currentAST, tmp14_AST); |
294 | match(STR_LITERAL); |
295 | genexpr_AST = (AST)currentAST.root; |
296 | break; |
297 | } |
298 | default: |
299 | { |
300 | throw new NoViableAltException(LT(1), getFilename()); |
301 | } |
302 | } |
303 | } |
304 | catch (RecognitionException ex) { |
305 | reportError(ex); |
306 | recover(ex,_tokenSet_3); |
307 | } |
308 | returnAST = genexpr_AST; |
309 | } |
310 | |
311 | |
312 | public static final String[] _tokenNames = { |
313 | "<0>", |
314 | "EOF", |
315 | "<2>", |
316 | "NULL_TREE_LOOKAHEAD", |
317 | "OR", |
318 | "AND", |
319 | "LPAREN", |
320 | "RPAREN", |
321 | "LT", |
322 | "LE", |
323 | "GT", |
324 | "GE", |
325 | "EQ", |
326 | "NE", |
327 | "BOOL_PROPERTY", |
328 | "PROPERTY", |
329 | "NUM_LITERAL", |
330 | "STR_LITERAL", |
331 | "WS", |
332 | "DOT", |
333 | "ID" |
334 | }; |
335 | |
336 | protected void buildTokenTypeASTClassMap() { |
337 | tokenTypeToASTClassMap=null; |
338 | }; |
339 | |
340 | private static final long[] mk_tokenSet_0() { |
341 | long[] data = { 128L, 0L}; |
342 | return data; |
343 | } |
344 | public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); |
345 | private static final long[] mk_tokenSet_1() { |
346 | long[] data = { 144L, 0L}; |
347 | return data; |
348 | } |
349 | public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1()); |
350 | private static final long[] mk_tokenSet_2() { |
351 | long[] data = { 176L, 0L}; |
352 | return data; |
353 | } |
354 | public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2()); |
355 | private static final long[] mk_tokenSet_3() { |
356 | long[] data = { 16304L, 0L}; |
357 | return data; |
358 | } |
359 | public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3()); |
360 | |
361 | } |