1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.common.messagebuilder.booleanmessage.ast.parsers;
18
19 import java.util.List;
20
21 import org.antlr.runtime.BitSet;
22 import org.antlr.runtime.NoViableAltException;
23 import org.antlr.runtime.Parser;
24 import org.antlr.runtime.ParserRuleReturnScope;
25 import org.antlr.runtime.RecognitionException;
26 import org.antlr.runtime.RecognizerSharedState;
27 import org.antlr.runtime.Token;
28 import org.antlr.runtime.TokenStream;
29 import org.antlr.runtime.tree.CommonTreeAdaptor;
30 import org.antlr.runtime.tree.TreeAdaptor;
31
32 public class BooleanFunctionParser extends Parser {
33 public static final String[] tokenNames = new String[] {
34 "<invalid>", "<EOR>", "<DOWN>", "<UP>", "OR", "AND", "LP", "RP", "ALPHA", "UPPERCASE", "NUMBER", "WHITESPACE", "LOWERCASE"
35 };
36 public static final int UPPERCASE=9;
37 public static final int LOWERCASE=12;
38 public static final int RP=7;
39 public static final int OR=4;
40 public static final int NUMBER=10;
41 public static final int LP=6;
42 public static final int WHITESPACE=11;
43 public static final int AND=5;
44 public static final int EOF=-1;
45 public static final int ALPHA=8;
46
47
48
49
50
51 public BooleanFunctionParser(TokenStream input) {
52 this(input, new RecognizerSharedState());
53 }
54 public BooleanFunctionParser(TokenStream input, RecognizerSharedState state) {
55 super(input, state);
56
57 }
58
59 protected TreeAdaptor adaptor = new CommonTreeAdaptor();
60
61 public void setTreeAdaptor(TreeAdaptor adaptor) {
62 this.adaptor = adaptor;
63 }
64 public TreeAdaptor getTreeAdaptor() {
65 return adaptor;
66 }
67
68 public String[] getTokenNames() { return BooleanFunctionParser.tokenNames; }
69 public String getGrammarFileName() { return "BooleanFunction.g"; }
70
71
72 @Override
73 public String getErrorMessage(RecognitionException e, String[] tokenNames) {
74 List<?> stack = getRuleInvocationStack(e, this.getClass().getName());
75 String msg = null;
76 if ( e instanceof NoViableAltException ) {
77 NoViableAltException nvae = (NoViableAltException)e;
78 msg = " No viable alternatives; token=" + e.token
79 + " (decision=" + nvae.decisionNumber
80 + " state " + nvae.stateNumber+")"
81 + " decision=<<" + nvae.grammarDecisionDescription + ">>";
82 }
83 else {
84 msg = super.getErrorMessage(e, tokenNames);
85 }
86 return stack + " " + msg;
87 }
88
89 @Override
90 public String getTokenErrorDisplay(Token t) {
91 return t.toString();
92 }
93
94 private boolean isTokenParenthesis(String paren){
95 if (paren != null) {
96 if ( paren.equals("(") || paren.equals(")") )
97 return true;
98 }
99 return false;
100 }
101
102
103 public static class booleanExpression_return extends ParserRuleReturnScope {
104 Object tree;
105 public Object getTree() { return tree; }
106 };
107
108
109
110 public final BooleanFunctionParser.booleanExpression_return booleanExpression() throws RecognitionException {
111 BooleanFunctionParser.booleanExpression_return retval = new BooleanFunctionParser.booleanExpression_return();
112 retval.start = input.LT(1);
113
114 Object root_0 = null;
115
116 BooleanFunctionParser.orTerm_return orTerm1 = null;
117
118
119
120 try {
121
122
123 {
124 root_0 = (Object)adaptor.nil();
125
126 pushFollow(FOLLOW_orTerm_in_booleanExpression111);
127 orTerm1=orTerm();
128
129 state._fsp--;
130
131 adaptor.addChild(root_0, orTerm1.getTree());
132 if ( isTokenParenthesis(input.LT(1).getText()) ) throw new RecognitionException();
133
134 }
135
136 retval.stop = input.LT(-1);
137
138 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
139 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
140
141 }
142
143 catch (RecognitionException e) {
144 throw e;
145 }
146 finally {
147 }
148 return retval;
149 }
150
151
152 public static class orTerm_return extends ParserRuleReturnScope {
153 Object tree;
154 public Object getTree() { return tree; }
155 };
156
157
158
159 public final BooleanFunctionParser.orTerm_return orTerm() throws RecognitionException {
160 BooleanFunctionParser.orTerm_return retval = new BooleanFunctionParser.orTerm_return();
161 retval.start = input.LT(1);
162
163 Object root_0 = null;
164
165 Token OR3=null;
166 BooleanFunctionParser.andTerm_return andTerm2 = null;
167
168 BooleanFunctionParser.andTerm_return andTerm4 = null;
169
170
171 Object OR3_tree=null;
172
173 try {
174
175
176 {
177 root_0 = (Object)adaptor.nil();
178
179 pushFollow(FOLLOW_andTerm_in_orTerm123);
180 andTerm2=andTerm();
181
182 state._fsp--;
183
184 adaptor.addChild(root_0, andTerm2.getTree());
185
186 loop1:
187 do {
188 int alt1=2;
189 int LA1_0 = input.LA(1);
190
191 if ( (LA1_0==OR) ) {
192 alt1=1;
193 }
194
195
196 switch (alt1) {
197 case 1 :
198
199 {
200 OR3=(Token)match(input,OR,FOLLOW_OR_in_orTerm126);
201 OR3_tree = (Object)adaptor.create(OR3);
202 root_0 = (Object)adaptor.becomeRoot(OR3_tree, root_0);
203
204 pushFollow(FOLLOW_andTerm_in_orTerm129);
205 andTerm4=andTerm();
206
207 state._fsp--;
208
209 adaptor.addChild(root_0, andTerm4.getTree());
210
211 }
212 break;
213
214 default :
215 break loop1;
216 }
217 } while (true);
218
219
220 }
221
222 retval.stop = input.LT(-1);
223
224 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
225 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
226
227 }
228
229 catch (RecognitionException e) {
230 throw e;
231 }
232 finally {
233 }
234 return retval;
235 }
236
237
238 public static class andTerm_return extends ParserRuleReturnScope {
239 Object tree;
240 public Object getTree() { return tree; }
241 };
242
243
244
245 public final BooleanFunctionParser.andTerm_return andTerm() throws RecognitionException {
246 BooleanFunctionParser.andTerm_return retval = new BooleanFunctionParser.andTerm_return();
247 retval.start = input.LT(1);
248
249 Object root_0 = null;
250
251 Token AND6=null;
252 BooleanFunctionParser.atom_return atom5 = null;
253
254 BooleanFunctionParser.atom_return atom7 = null;
255
256
257 Object AND6_tree=null;
258
259 try {
260
261
262 {
263 root_0 = (Object)adaptor.nil();
264
265 pushFollow(FOLLOW_atom_in_andTerm140);
266 atom5=atom();
267
268 state._fsp--;
269
270 adaptor.addChild(root_0, atom5.getTree());
271
272 loop2:
273 do {
274 int alt2=2;
275 int LA2_0 = input.LA(1);
276
277 if ( (LA2_0==AND) ) {
278 alt2=1;
279 }
280
281
282 switch (alt2) {
283 case 1 :
284
285 {
286 AND6=(Token)match(input,AND,FOLLOW_AND_in_andTerm143);
287 AND6_tree = (Object)adaptor.create(AND6);
288 root_0 = (Object)adaptor.becomeRoot(AND6_tree, root_0);
289
290 pushFollow(FOLLOW_atom_in_andTerm146);
291 atom7=atom();
292
293 state._fsp--;
294
295 adaptor.addChild(root_0, atom7.getTree());
296
297 }
298 break;
299
300 default :
301 break loop2;
302 }
303 } while (true);
304
305
306 }
307
308 retval.stop = input.LT(-1);
309
310 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
311 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
312
313 }
314
315 catch (RecognitionException e) {
316 throw e;
317 }
318 finally {
319 }
320 return retval;
321 }
322
323
324 public static class atom_return extends ParserRuleReturnScope {
325 Object tree;
326 public Object getTree() { return tree; }
327 };
328
329
330
331 public final BooleanFunctionParser.atom_return atom() throws RecognitionException {
332 BooleanFunctionParser.atom_return retval = new BooleanFunctionParser.atom_return();
333 retval.start = input.LT(1);
334
335 Object root_0 = null;
336
337 Token ALPHA8=null;
338 Token LP9=null;
339 Token RP11=null;
340 BooleanFunctionParser.orTerm_return orTerm10 = null;
341
342
343 Object ALPHA8_tree=null;
344 Object LP9_tree=null;
345 Object RP11_tree=null;
346
347 try {
348
349 int alt3=2;
350 int LA3_0 = input.LA(1);
351
352 if ( (LA3_0==ALPHA) ) {
353 alt3=1;
354 }
355 else if ( (LA3_0==LP) ) {
356 alt3=2;
357 }
358 else {
359 NoViableAltException nvae =
360 new NoViableAltException("", 3, 0, input);
361
362 throw nvae;
363 }
364 switch (alt3) {
365 case 1 :
366
367 {
368 root_0 = (Object)adaptor.nil();
369
370 ALPHA8=(Token)match(input,ALPHA,FOLLOW_ALPHA_in_atom160);
371 ALPHA8_tree = (Object)adaptor.create(ALPHA8);
372 adaptor.addChild(root_0, ALPHA8_tree);
373
374
375 }
376 break;
377 case 2 :
378
379 {
380 root_0 = (Object)adaptor.nil();
381
382
383
384 {
385 LP9=(Token)match(input,LP,FOLLOW_LP_in_atom165);
386 pushFollow(FOLLOW_orTerm_in_atom168);
387 orTerm10=orTerm();
388
389 state._fsp--;
390
391 adaptor.addChild(root_0, orTerm10.getTree());
392 RP11=(Token)match(input,RP,FOLLOW_RP_in_atom170);
393
394 }
395
396
397 }
398 break;
399
400 }
401 retval.stop = input.LT(-1);
402
403 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
404 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
405
406 }
407
408 catch (RecognitionException e) {
409 throw e;
410 }
411 finally {
412 }
413 return retval;
414 }
415
416
417
418
419
420
421
422 public static final BitSet FOLLOW_orTerm_in_booleanExpression111 = new BitSet(new long[]{0x0000000000000002L});
423 public static final BitSet FOLLOW_andTerm_in_orTerm123 = new BitSet(new long[]{0x0000000000000012L});
424 public static final BitSet FOLLOW_OR_in_orTerm126 = new BitSet(new long[]{0x0000000000000140L});
425 public static final BitSet FOLLOW_andTerm_in_orTerm129 = new BitSet(new long[]{0x0000000000000012L});
426 public static final BitSet FOLLOW_atom_in_andTerm140 = new BitSet(new long[]{0x0000000000000022L});
427 public static final BitSet FOLLOW_AND_in_andTerm143 = new BitSet(new long[]{0x0000000000000140L});
428 public static final BitSet FOLLOW_atom_in_andTerm146 = new BitSet(new long[]{0x0000000000000022L});
429 public static final BitSet FOLLOW_ALPHA_in_atom160 = new BitSet(new long[]{0x0000000000000002L});
430 public static final BitSet FOLLOW_LP_in_atom165 = new BitSet(new long[]{0x0000000000000140L});
431 public static final BitSet FOLLOW_orTerm_in_atom168 = new BitSet(new long[]{0x0000000000000080L});
432 public static final BitSet FOLLOW_RP_in_atom170 = new BitSet(new long[]{0x0000000000000002L});
433
434 }