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