Coverage Report - org.kuali.student.common.messagebuilder.booleanmessage.ast.parsers.BooleanFunctionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
BooleanFunctionParser
0%
0/162
0%
0/25
2.529
BooleanFunctionParser$andTerm_return
0%
0/2
N/A
2.529
BooleanFunctionParser$atom_return
0%
0/2
N/A
2.529
BooleanFunctionParser$booleanExpression_return
0%
0/2
N/A
2.529
BooleanFunctionParser$orTerm_return
0%
0/2
N/A
2.529
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 // $ANTLR 3.1.1 BooleanFunction.g 2009-06-03 01:05:39
 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  0
     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  
     // delegates
 48  
     // delegators
 49  
 
 50  
 
 51  
         public BooleanFunctionParser(TokenStream input) {
 52  0
             this(input, new RecognizerSharedState());
 53  0
         }
 54  
         public BooleanFunctionParser(TokenStream input, RecognizerSharedState state) {
 55  0
             super(input, state);
 56  
 
 57  0
         }
 58  
 
 59  0
     protected TreeAdaptor adaptor = new CommonTreeAdaptor();
 60  
 
 61  
     public void setTreeAdaptor(TreeAdaptor adaptor) {
 62  0
         this.adaptor = adaptor;
 63  0
     }
 64  
     public TreeAdaptor getTreeAdaptor() {
 65  0
         return adaptor;
 66  
     }
 67  
 
 68  0
     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  0
         List<?> stack = getRuleInvocationStack(e, this.getClass().getName());
 75  0
         String msg = null;
 76  0
         if ( e instanceof NoViableAltException ) {
 77  0
            NoViableAltException nvae = (NoViableAltException)e;
 78  0
            msg = " No viable alternatives; token=" + e.token
 79  
               + " (decision=" + nvae.decisionNumber
 80  
               + " state " + nvae.stateNumber+")"
 81  
               + " decision=<<" + nvae.grammarDecisionDescription + ">>";
 82  0
         }
 83  
         else {
 84  0
            msg = super.getErrorMessage(e, tokenNames);
 85  
         }
 86  0
         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  0
         if (paren != null) {
 96  0
             if ( paren.equals("(") || paren.equals(")") )
 97  0
                 return true;
 98  
         }
 99  0
         return false;
 100  
     }
 101  
 
 102  
 
 103  0
     public static class booleanExpression_return extends ParserRuleReturnScope {
 104  
         Object tree;
 105  0
         public Object getTree() { return tree; }
 106  
     };
 107  
 
 108  
     // $ANTLR start "booleanExpression"
 109  
     // BooleanFunction.g:60:1: booleanExpression : orTerm ;
 110  
     public final BooleanFunctionParser.booleanExpression_return booleanExpression() throws RecognitionException {
 111  0
         BooleanFunctionParser.booleanExpression_return retval = new BooleanFunctionParser.booleanExpression_return();
 112  0
         retval.start = input.LT(1);
 113  
 
 114  0
         Object root_0 = null;
 115  
 
 116  0
         BooleanFunctionParser.orTerm_return orTerm1 = null;
 117  
 
 118  
 
 119  
 
 120  
         try {
 121  
             // BooleanFunction.g:60:18: ( orTerm )
 122  
             // BooleanFunction.g:60:22: orTerm
 123  
             {
 124  0
             root_0 = (Object)adaptor.nil();
 125  
 
 126  0
             pushFollow(FOLLOW_orTerm_in_booleanExpression111);
 127  0
             orTerm1=orTerm();
 128  
 
 129  0
             state._fsp--;
 130  
 
 131  0
             adaptor.addChild(root_0, orTerm1.getTree());
 132  0
             if ( isTokenParenthesis(input.LT(1).getText()) ) throw new RecognitionException();
 133  
 
 134  
             }
 135  
 
 136  0
             retval.stop = input.LT(-1);
 137  
 
 138  0
             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
 139  0
             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
 140  
 
 141  
         }
 142  
 
 143  0
         catch (RecognitionException e) {
 144  0
             throw e;
 145  
         }
 146  0
         finally {
 147  0
         }
 148  0
         return retval;
 149  
     }
 150  
     // $ANTLR end "booleanExpression"
 151  
 
 152  0
     public static class orTerm_return extends ParserRuleReturnScope {
 153  
         Object tree;
 154  0
         public Object getTree() { return tree; }
 155  
     };
 156  
 
 157  
     // $ANTLR start "orTerm"
 158  
     // BooleanFunction.g:61:1: orTerm : andTerm ( OR andTerm )* ;
 159  
     public final BooleanFunctionParser.orTerm_return orTerm() throws RecognitionException {
 160  0
         BooleanFunctionParser.orTerm_return retval = new BooleanFunctionParser.orTerm_return();
 161  0
         retval.start = input.LT(1);
 162  
 
 163  0
         Object root_0 = null;
 164  
 
 165  0
         Token OR3=null;
 166  0
         BooleanFunctionParser.andTerm_return andTerm2 = null;
 167  
 
 168  0
         BooleanFunctionParser.andTerm_return andTerm4 = null;
 169  
 
 170  
 
 171  0
         Object OR3_tree=null;
 172  
 
 173  
         try {
 174  
             // BooleanFunction.g:61:9: ( andTerm ( OR andTerm )* )
 175  
             // BooleanFunction.g:61:13: andTerm ( OR andTerm )*
 176  
             {
 177  0
             root_0 = (Object)adaptor.nil();
 178  
 
 179  0
             pushFollow(FOLLOW_andTerm_in_orTerm123);
 180  0
             andTerm2=andTerm();
 181  
 
 182  0
             state._fsp--;
 183  
 
 184  0
             adaptor.addChild(root_0, andTerm2.getTree());
 185  
             // BooleanFunction.g:61:21: ( OR andTerm )*
 186  
             loop1:
 187  
             do {
 188  0
                 int alt1=2;
 189  0
                 int LA1_0 = input.LA(1);
 190  
 
 191  0
                 if ( (LA1_0==OR) ) {
 192  0
                     alt1=1;
 193  
                 }
 194  
 
 195  
 
 196  0
                 switch (alt1) {
 197  
                     case 1 :
 198  
                         // BooleanFunction.g:61:22: OR andTerm
 199  
                         {
 200  0
                         OR3=(Token)match(input,OR,FOLLOW_OR_in_orTerm126);
 201  0
                         OR3_tree = (Object)adaptor.create(OR3);
 202  0
                         root_0 = (Object)adaptor.becomeRoot(OR3_tree, root_0);
 203  
 
 204  0
                         pushFollow(FOLLOW_andTerm_in_orTerm129);
 205  0
                         andTerm4=andTerm();
 206  
 
 207  0
                         state._fsp--;
 208  
 
 209  0
                         adaptor.addChild(root_0, andTerm4.getTree());
 210  
 
 211  
                         }
 212  0
                         break;
 213  
 
 214  
                     default :
 215  0
                         break loop1;
 216  
                 }
 217  0
             } while (true);
 218  
 
 219  
 
 220  
             }
 221  
 
 222  0
             retval.stop = input.LT(-1);
 223  
 
 224  0
             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
 225  0
             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
 226  
 
 227  
         }
 228  
 
 229  0
         catch (RecognitionException e) {
 230  0
             throw e;
 231  
         }
 232  0
         finally {
 233  0
         }
 234  0
         return retval;
 235  
     }
 236  
     // $ANTLR end "orTerm"
 237  
 
 238  0
     public static class andTerm_return extends ParserRuleReturnScope {
 239  
         Object tree;
 240  0
         public Object getTree() { return tree; }
 241  
     };
 242  
 
 243  
     // $ANTLR start "andTerm"
 244  
     // BooleanFunction.g:62:1: andTerm : atom ( AND atom )* ;
 245  
     public final BooleanFunctionParser.andTerm_return andTerm() throws RecognitionException {
 246  0
         BooleanFunctionParser.andTerm_return retval = new BooleanFunctionParser.andTerm_return();
 247  0
         retval.start = input.LT(1);
 248  
 
 249  0
         Object root_0 = null;
 250  
 
 251  0
         Token AND6=null;
 252  0
         BooleanFunctionParser.atom_return atom5 = null;
 253  
 
 254  0
         BooleanFunctionParser.atom_return atom7 = null;
 255  
 
 256  
 
 257  0
         Object AND6_tree=null;
 258  
 
 259  
         try {
 260  
             // BooleanFunction.g:62:9: ( atom ( AND atom )* )
 261  
             // BooleanFunction.g:62:13: atom ( AND atom )*
 262  
             {
 263  0
             root_0 = (Object)adaptor.nil();
 264  
 
 265  0
             pushFollow(FOLLOW_atom_in_andTerm140);
 266  0
             atom5=atom();
 267  
 
 268  0
             state._fsp--;
 269  
 
 270  0
             adaptor.addChild(root_0, atom5.getTree());
 271  
             // BooleanFunction.g:62:18: ( AND atom )*
 272  
             loop2:
 273  
             do {
 274  0
                 int alt2=2;
 275  0
                 int LA2_0 = input.LA(1);
 276  
 
 277  0
                 if ( (LA2_0==AND) ) {
 278  0
                     alt2=1;
 279  
                 }
 280  
 
 281  
 
 282  0
                 switch (alt2) {
 283  
                     case 1 :
 284  
                         // BooleanFunction.g:62:19: AND atom
 285  
                         {
 286  0
                         AND6=(Token)match(input,AND,FOLLOW_AND_in_andTerm143);
 287  0
                         AND6_tree = (Object)adaptor.create(AND6);
 288  0
                         root_0 = (Object)adaptor.becomeRoot(AND6_tree, root_0);
 289  
 
 290  0
                         pushFollow(FOLLOW_atom_in_andTerm146);
 291  0
                         atom7=atom();
 292  
 
 293  0
                         state._fsp--;
 294  
 
 295  0
                         adaptor.addChild(root_0, atom7.getTree());
 296  
 
 297  
                         }
 298  0
                         break;
 299  
 
 300  
                     default :
 301  0
                         break loop2;
 302  
                 }
 303  0
             } while (true);
 304  
 
 305  
 
 306  
             }
 307  
 
 308  0
             retval.stop = input.LT(-1);
 309  
 
 310  0
             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
 311  0
             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
 312  
 
 313  
         }
 314  
 
 315  0
         catch (RecognitionException e) {
 316  0
             throw e;
 317  
         }
 318  0
         finally {
 319  0
         }
 320  0
         return retval;
 321  
     }
 322  
     // $ANTLR end "andTerm"
 323  
 
 324  0
     public static class atom_return extends ParserRuleReturnScope {
 325  
         Object tree;
 326  0
         public Object getTree() { return tree; }
 327  
     };
 328  
 
 329  
     // $ANTLR start "atom"
 330  
     // BooleanFunction.g:63:1: atom : ( ALPHA | ( LP orTerm RP ) );
 331  
     public final BooleanFunctionParser.atom_return atom() throws RecognitionException {
 332  0
         BooleanFunctionParser.atom_return retval = new BooleanFunctionParser.atom_return();
 333  0
         retval.start = input.LT(1);
 334  
 
 335  0
         Object root_0 = null;
 336  
 
 337  0
         Token ALPHA8=null;
 338  0
         Token LP9=null;
 339  0
         Token RP11=null;
 340  0
         BooleanFunctionParser.orTerm_return orTerm10 = null;
 341  
 
 342  
 
 343  0
         Object ALPHA8_tree=null;
 344  0
         Object LP9_tree=null;
 345  0
         Object RP11_tree=null;
 346  
 
 347  
         try {
 348  
             // BooleanFunction.g:63:9: ( ALPHA | ( LP orTerm RP ) )
 349  0
             int alt3=2;
 350  0
             int LA3_0 = input.LA(1);
 351  
 
 352  0
             if ( (LA3_0==ALPHA) ) {
 353  0
                 alt3=1;
 354  
             }
 355  0
             else if ( (LA3_0==LP) ) {
 356  0
                 alt3=2;
 357  
             }
 358  
             else {
 359  0
                 NoViableAltException nvae =
 360  
                     new NoViableAltException("", 3, 0, input);
 361  
 
 362  0
                 throw nvae;
 363  
             }
 364  0
             switch (alt3) {
 365  
                 case 1 :
 366  
                     // BooleanFunction.g:63:13: ALPHA
 367  
                     {
 368  0
                     root_0 = (Object)adaptor.nil();
 369  
 
 370  0
                     ALPHA8=(Token)match(input,ALPHA,FOLLOW_ALPHA_in_atom160);
 371  0
                     ALPHA8_tree = (Object)adaptor.create(ALPHA8);
 372  0
                     adaptor.addChild(root_0, ALPHA8_tree);
 373  
 
 374  
 
 375  
                     }
 376  0
                     break;
 377  
                 case 2 :
 378  
                     // BooleanFunction.g:63:21: ( LP orTerm RP )
 379  
                     {
 380  0
                     root_0 = (Object)adaptor.nil();
 381  
 
 382  
                     // BooleanFunction.g:63:21: ( LP orTerm RP )
 383  
                     // BooleanFunction.g:63:22: LP orTerm RP
 384  
                     {
 385  0
                     LP9=(Token)match(input,LP,FOLLOW_LP_in_atom165);
 386  0
                     pushFollow(FOLLOW_orTerm_in_atom168);
 387  0
                     orTerm10=orTerm();
 388  
 
 389  0
                     state._fsp--;
 390  
 
 391  0
                     adaptor.addChild(root_0, orTerm10.getTree());
 392  0
                     RP11=(Token)match(input,RP,FOLLOW_RP_in_atom170);
 393  
 
 394  
                     }
 395  
 
 396  
 
 397  
                     }
 398  
                     break;
 399  
 
 400  
             }
 401  0
             retval.stop = input.LT(-1);
 402  
 
 403  0
             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
 404  0
             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
 405  
 
 406  
         }
 407  
 
 408  0
         catch (RecognitionException e) {
 409  0
             throw e;
 410  
         }
 411  0
         finally {
 412  0
         }
 413  0
         return retval;
 414  
     }
 415  
     // $ANTLR end "atom"
 416  
 
 417  
     // Delegated rules
 418  
 
 419  
 
 420  
 
 421  
 
 422  0
     public static final BitSet FOLLOW_orTerm_in_booleanExpression111 = new BitSet(new long[]{0x0000000000000002L});
 423  0
     public static final BitSet FOLLOW_andTerm_in_orTerm123 = new BitSet(new long[]{0x0000000000000012L});
 424  0
     public static final BitSet FOLLOW_OR_in_orTerm126 = new BitSet(new long[]{0x0000000000000140L});
 425  0
     public static final BitSet FOLLOW_andTerm_in_orTerm129 = new BitSet(new long[]{0x0000000000000012L});
 426  0
     public static final BitSet FOLLOW_atom_in_andTerm140 = new BitSet(new long[]{0x0000000000000022L});
 427  0
     public static final BitSet FOLLOW_AND_in_andTerm143 = new BitSet(new long[]{0x0000000000000140L});
 428  0
     public static final BitSet FOLLOW_atom_in_andTerm146 = new BitSet(new long[]{0x0000000000000022L});
 429  0
     public static final BitSet FOLLOW_ALPHA_in_atom160 = new BitSet(new long[]{0x0000000000000002L});
 430  0
     public static final BitSet FOLLOW_LP_in_atom165 = new BitSet(new long[]{0x0000000000000140L});
 431  0
     public static final BitSet FOLLOW_orTerm_in_atom168 = new BitSet(new long[]{0x0000000000000080L});
 432  0
     public static final BitSet FOLLOW_RP_in_atom170 = new BitSet(new long[]{0x0000000000000002L});
 433  
 
 434  
 }