Package antlr

Examples of antlr.ASTPair


*  Only labeled, unparameterized blocks which occur directly as substatements are kept open.
*/
  public final void closableBlock() throws RecognitionException, TokenStreamException {
   
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST closableBlock_AST = null;
    AST cbp_AST = null;
    AST bb_AST = null;
    Token first = LT(1);
   
    match(LCURLY);
    nls();
    closableBlockParamsOpt(true);
    cbp_AST = (AST)returnAST;
    blockBody(EOF);
    bb_AST = (AST)returnAST;
    match(RCURLY);
    if ( inputState.guessing==0 ) {
      closableBlock_AST = (AST)currentAST.root;
      closableBlock_AST = (AST)astFactory.make( (new ASTArray(3)).add(create(CLOSABLE_BLOCK,"{",first,LT(1))).add(cbp_AST).add(bb_AST));
      currentAST.root = closableBlock_AST;
      currentAST.child = closableBlock_AST!=null &&closableBlock_AST.getFirstChild()!=null ?
        closableBlock_AST.getFirstChild() : closableBlock_AST;
      currentAST.advanceChildToEnd();
    }
    closableBlock_AST = (AST)currentAST.root;
    returnAST = closableBlock_AST;
  }
View Full Code Here


*  which is given closure arguments, even if they are not explicit in the code.
*/
  public final void openOrClosableBlock() throws RecognitionException, TokenStreamException {
   
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST openOrClosableBlock_AST = null;
    AST cp_AST = null;
    AST bb_AST = null;
    Token first = LT(1);
   
    match(LCURLY);
    nls();
    closableBlockParamsOpt(false);
    cp_AST = (AST)returnAST;
    blockBody(EOF);
    bb_AST = (AST)returnAST;
    match(RCURLY);
    if ( inputState.guessing==0 ) {
      openOrClosableBlock_AST = (AST)currentAST.root;
     
      if (cp_AST == null)    openOrClosableBlock_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(SLIST,"{",first,LT(1))).add(bb_AST));
      else                openOrClosableBlock_AST = (AST)astFactory.make( (new ASTArray(3)).add(create(CLOSABLE_BLOCK,"{",first,LT(1))).add(cp_AST).add(bb_AST));
     
      currentAST.root = openOrClosableBlock_AST;
      currentAST.child = openOrClosableBlock_AST!=null &&openOrClosableBlock_AST.getFirstChild()!=null ?
        openOrClosableBlock_AST.getFirstChild() : openOrClosableBlock_AST;
      currentAST.advanceChildToEnd();
    }
    openOrClosableBlock_AST = (AST)currentAST.root;
    returnAST = openOrClosableBlock_AST;
  }
View Full Code Here

 
/** A labeled statement, consisting of a vanilla identifier followed by a colon. */
  public final void statementLabelPrefix() throws RecognitionException, TokenStreamException {
   
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST statementLabelPrefix_AST = null;
    Token  c = null;
    AST c_AST = null;
   
    AST tmp220_AST = null;
View Full Code Here

  public final void expressionStatement(
    int prevToken
  ) throws RecognitionException, TokenStreamException {
   
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST expressionStatement_AST = null;
    AST esn_AST = null;
    Token first = LT(1);
   
    {
    boolean synPredMatched329 = false;
    if (((_tokenSet_19.member(LA(1))) && (_tokenSet_1.member(LA(2))))) {
      int _m329 = mark();
      synPredMatched329 = true;
      inputState.guessing++;
      try {
        {
        suspiciousExpressionStatementStart();
        }
      }
      catch (RecognitionException pe) {
        synPredMatched329 = false;
      }
      rewind(_m329);
inputState.guessing--;
    }
    if ( synPredMatched329 ) {
      checkSuspiciousExpressionStatement(prevToken);
      astFactory.addASTChild(currentAST, returnAST);
    }
    else if ((_tokenSet_19.member(LA(1))) && (_tokenSet_1.member(LA(2)))) {
    }
    else {
      throw new NoViableAltException(LT(1), getFilename());
    }
   
    }
    expressionStatementNoCheck();
    esn_AST = (AST)returnAST;
    astFactory.addASTChild(currentAST, returnAST);
    if ( inputState.guessing==0 ) {
      expressionStatement_AST = (AST)currentAST.root;
      expressionStatement_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(EXPR,"EXPR",first,LT(1))).add(esn_AST));
      currentAST.root = expressionStatement_AST;
      currentAST.child = expressionStatement_AST!=null &&expressionStatement_AST.getFirstChild()!=null ?
        expressionStatement_AST.getFirstChild() : expressionStatement_AST;
      currentAST.advanceChildToEnd();
    }
    expressionStatement_AST = (AST)currentAST.root;
    returnAST = expressionStatement_AST;
  }
View Full Code Here

  }
 
  public final void assignmentLessExpression() throws RecognitionException, TokenStreamException {
   
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST assignmentLessExpression_AST = null;
    Token first = LT(1);
   
    {
    conditionalExpression(0);
    astFactory.addASTChild(currentAST, returnAST);
    }
    if ( inputState.guessing==0 ) {
      assignmentLessExpression_AST = (AST)currentAST.root;
      assignmentLessExpression_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(EXPR,"EXPR",first,LT(1))).add(assignmentLessExpression_AST));
      currentAST.root = assignmentLessExpression_AST;
      currentAST.child = assignmentLessExpression_AST!=null &&assignmentLessExpression_AST.getFirstChild()!=null ?
        assignmentLessExpression_AST.getFirstChild() : assignmentLessExpression_AST;
      currentAST.advanceChildToEnd();
    }
    assignmentLessExpression_AST = (AST)currentAST.root;
    returnAST = assignmentLessExpression_AST;
  }
View Full Code Here

*  Support this practice, even though it isn't very Groovy.
*/
  public final void compatibleBodyStatement() throws RecognitionException, TokenStreamException {
   
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST compatibleBodyStatement_AST = null;
   
    boolean synPredMatched318 = false;
    if (((LA(1)==LCURLY) && (_tokenSet_30.member(LA(2))))) {
      int _m318 = mark();
View Full Code Here

  }
 
  public final void forStatement() throws RecognitionException, TokenStreamException {
   
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST forStatement_AST = null;
    AST cl_AST = null;
    AST fic_AST = null;
    Token  s = null;
    AST s_AST = null;
    AST forCbs_AST = null;
    Token first = LT(1);
   
    match(LITERAL_for);
    match(LPAREN);
    {
    boolean synPredMatched305 = false;
    if (((_tokenSet_76.member(LA(1))) && (_tokenSet_77.member(LA(2))))) {
      int _m305 = mark();
      synPredMatched305 = true;
      inputState.guessing++;
      try {
        {
        switch ( LA(1)) {
        case SEMI:
        {
          match(SEMI);
          break;
        }
        case FINAL:
        case ABSTRACT:
        case STRICTFP:
        case LITERAL_static:
        case LITERAL_def:
        case LBRACK:
        case IDENT:
        case STRING_LITERAL:
        case LPAREN:
        case AT:
        case LITERAL_super:
        case LITERAL_void:
        case LITERAL_boolean:
        case LITERAL_byte:
        case LITERAL_char:
        case LITERAL_short:
        case LITERAL_int:
        case LITERAL_float:
        case LITERAL_long:
        case LITERAL_double:
        case LITERAL_private:
        case LITERAL_public:
        case LITERAL_protected:
        case LITERAL_transient:
        case LITERAL_native:
        case LITERAL_threadsafe:
        case LITERAL_synchronized:
        case LITERAL_volatile:
        case LCURLY:
        case LITERAL_this:
        case LITERAL_return:
        case LITERAL_break:
        case LITERAL_continue:
        case LITERAL_throw:
        case LITERAL_assert:
        case PLUS:
        case MINUS:
        case LITERAL_false:
        case LITERAL_new:
        case LITERAL_null:
        case LITERAL_true:
        case INC:
        case DEC:
        case BNOT:
        case LNOT:
        case STRING_CTOR_START:
        case NUM_INT:
        case NUM_FLOAT:
        case NUM_LONG:
        case NUM_DOUBLE:
        case NUM_BIG_INT:
        case NUM_BIG_DECIMAL:
        {
          {
          strictContextExpression(true);
          match(SEMI);
          }
          break;
        }
        default:
        {
          throw new NoViableAltException(LT(1), getFilename());
        }
        }
        }
      }
      catch (RecognitionException pe) {
        synPredMatched305 = false;
      }
      rewind(_m305);
inputState.guessing--;
    }
    if ( synPredMatched305 ) {
      closureList();
      cl_AST = (AST)returnAST;
    }
    else if ((_tokenSet_15.member(LA(1))) && (_tokenSet_78.member(LA(2)))) {
      forInClause();
      fic_AST = (AST)returnAST;
    }
    else {
      throw new NoViableAltException(LT(1), getFilename());
    }
   
    }
    match(RPAREN);
    nls();
    {
    switch ( LA(1)) {
    case SEMI:
    {
      s = LT(1);
      s_AST = astFactory.create(s);
      match(SEMI);
      break;
    }
    case FINAL:
    case ABSTRACT:
    case STRICTFP:
    case LITERAL_import:
    case LITERAL_static:
    case LITERAL_def:
    case LBRACK:
    case IDENT:
    case STRING_LITERAL:
    case LPAREN:
    case LITERAL_class:
    case LITERAL_interface:
    case LITERAL_enum:
    case AT:
    case LITERAL_super:
    case LITERAL_void:
    case LITERAL_boolean:
    case LITERAL_byte:
    case LITERAL_char:
    case LITERAL_short:
    case LITERAL_int:
    case LITERAL_float:
    case LITERAL_long:
    case LITERAL_double:
    case LITERAL_private:
    case LITERAL_public:
    case LITERAL_protected:
    case LITERAL_transient:
    case LITERAL_native:
    case LITERAL_threadsafe:
    case LITERAL_synchronized:
    case LITERAL_volatile:
    case LCURLY:
    case LITERAL_this:
    case LITERAL_if:
    case LITERAL_while:
    case LITERAL_switch:
    case LITERAL_for:
    case LITERAL_return:
    case LITERAL_break:
    case LITERAL_continue:
    case LITERAL_throw:
    case LITERAL_assert:
    case PLUS:
    case MINUS:
    case LITERAL_try:
    case LITERAL_false:
    case LITERAL_new:
    case LITERAL_null:
    case LITERAL_true:
    case INC:
    case DEC:
    case BNOT:
    case LNOT:
    case STRING_CTOR_START:
    case NUM_INT:
    case NUM_FLOAT:
    case NUM_LONG:
    case NUM_DOUBLE:
    case NUM_BIG_INT:
    case NUM_BIG_DECIMAL:
    {
      compatibleBodyStatement();
      forCbs_AST = (AST)returnAST;
      break;
    }
    default:
    {
      throw new NoViableAltException(LT(1), getFilename());
    }
    }
    }
    if ( inputState.guessing==0 ) {
      forStatement_AST = (AST)currentAST.root;
     
      if (cl_AST != null) {
      if (s_AST != null)
      forStatement_AST = (AST)astFactory.make( (new ASTArray(3)).add(create(LITERAL_for,"for",first,LT(1))).add(cl_AST).add(s_AST));
      else
      forStatement_AST = (AST)astFactory.make( (new ASTArray(3)).add(create(LITERAL_for,"for",first,LT(1))).add(cl_AST).add(forCbs_AST));
      } else {
      if (s_AST != null)
      forStatement_AST = (AST)astFactory.make( (new ASTArray(3)).add(create(LITERAL_for,"for",first,LT(1))).add(fic_AST).add(s_AST));
      else
      forStatement_AST = (AST)astFactory.make( (new ASTArray(3)).add(create(LITERAL_for,"for",first,LT(1))).add(fic_AST).add(forCbs_AST));
      }
     
      currentAST.root = forStatement_AST;
      currentAST.child = forStatement_AST!=null &&forStatement_AST.getFirstChild()!=null ?
        forStatement_AST.getFirstChild() : forStatement_AST;
      currentAST.advanceChildToEnd();
    }
    forStatement_AST = (AST)currentAST.root;
    returnAST = forStatement_AST;
  }
View Full Code Here

    boolean allowDeclaration
  ) throws RecognitionException, TokenStreamException {
    boolean hasDeclaration=false;
   
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST strictContextExpression_AST = null;
    Token first = LT(1);
   
    {
    boolean synPredMatched511 = false;
    if (((_tokenSet_15.member(LA(1))) && (_tokenSet_79.member(LA(2))))) {
      int _m511 = mark();
      synPredMatched511 = true;
      inputState.guessing++;
      try {
        {
        if (!(allowDeclaration))
          throw new SemanticException("allowDeclaration");
        declarationStart();
        }
      }
      catch (RecognitionException pe) {
        synPredMatched511 = false;
      }
      rewind(_m511);
inputState.guessing--;
    }
    if ( synPredMatched511 ) {
      if ( inputState.guessing==0 ) {
        hasDeclaration=true;
      }
      singleDeclaration();
      astFactory.addASTChild(currentAST, returnAST);
    }
    else if ((_tokenSet_19.member(LA(1))) && (_tokenSet_37.member(LA(2)))) {
      expression(0);
      astFactory.addASTChild(currentAST, returnAST);
    }
    else if (((LA(1) >= LITERAL_return && LA(1) <= LITERAL_assert))) {
      branchStatement();
      astFactory.addASTChild(currentAST, returnAST);
    }
    else if ((LA(1)==AT) && (LA(2)==IDENT)) {
      annotation();
      astFactory.addASTChild(currentAST, returnAST);
    }
    else {
      throw new NoViableAltException(LT(1), getFilename());
    }
   
    }
    if ( inputState.guessing==0 ) {
      strictContextExpression_AST = (AST)currentAST.root;
      strictContextExpression_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(EXPR,"EXPR",first,LT(1))).add(strictContextExpression_AST));
      currentAST.root = strictContextExpression_AST;
      currentAST.child = strictContextExpression_AST!=null &&strictContextExpression_AST.getFirstChild()!=null ?
        strictContextExpression_AST.getFirstChild() : strictContextExpression_AST;
      currentAST.advanceChildToEnd();
    }
    strictContextExpression_AST = (AST)currentAST.root;
    returnAST = strictContextExpression_AST;
    return hasDeclaration;
  }
View Full Code Here

  }
 
  public final void casesGroup() throws RecognitionException, TokenStreamException {
   
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST casesGroup_AST = null;
    Token first = LT(1);
   
    {
    int _cnt342=0;
    _loop342:
    do {
      if ((LA(1)==LITERAL_default||LA(1)==LITERAL_case)) {
        aCase();
        astFactory.addASTChild(currentAST, returnAST);
      }
      else {
        if ( _cnt342>=1 ) { break _loop342; } else {throw new NoViableAltException(LT(1), getFilename());}
      }
     
      _cnt342++;
    } while (true);
    }
    caseSList();
    astFactory.addASTChild(currentAST, returnAST);
    if ( inputState.guessing==0 ) {
      casesGroup_AST = (AST)currentAST.root;
      casesGroup_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(CASE_GROUP,"CASE_GROUP",first,LT(1))).add(casesGroup_AST));
      currentAST.root = casesGroup_AST;
      currentAST.child = casesGroup_AST!=null &&casesGroup_AST.getFirstChild()!=null ?
        casesGroup_AST.getFirstChild() : casesGroup_AST;
      currentAST.advanceChildToEnd();
    }
    casesGroup_AST = (AST)currentAST.root;
    returnAST = casesGroup_AST;
  }
View Full Code Here

  }
 
  public final void tryBlock() throws RecognitionException, TokenStreamException {
   
    returnAST = null;
    ASTPair currentAST = new ASTPair();
    AST tryBlock_AST = null;
    AST tryCs_AST = null;
    AST h_AST = null;
    AST fc_AST = null;
    Token first = LT(1);List catchNodes = new ArrayList();AST newHandler_AST = null;
   
    match(LITERAL_try);
    nlsWarn();
    compoundStatement();
    tryCs_AST = (AST)returnAST;
    {
    _loop359:
    do {
      if (((LA(1)==LITERAL_catch||LA(1)==NLS) && (LA(2)==LPAREN||LA(2)==LITERAL_catch))&&(!(LA(1) == NLS && LA(2) == LPAREN))) {
        nls();
        handler();
        h_AST = (AST)returnAST;
        if ( inputState.guessing==0 ) {
          newHandler_AST = (AST)astFactory.make( (new ASTArray(3)).add(null).add(newHandler_AST).add(h_AST));
        }
      }
      else {
        break _loop359;
      }
     
    } while (true);
    }
    {
    if ((LA(1)==LITERAL_finally||LA(1)==NLS) && (_tokenSet_80.member(LA(2)))) {
      nls();
      finallyClause();
      fc_AST = (AST)returnAST;
    }
    else if ((_tokenSet_10.member(LA(1))) && (_tokenSet_11.member(LA(2)))) {
    }
    else {
      throw new NoViableAltException(LT(1), getFilename());
    }
   
    }
    if ( inputState.guessing==0 ) {
      tryBlock_AST = (AST)currentAST.root;
      tryBlock_AST = (AST)astFactory.make( (new ASTArray(4)).add(create(LITERAL_try,"try",first,LT(1))).add(tryCs_AST).add(newHandler_AST).add(fc_AST));
      currentAST.root = tryBlock_AST;
      currentAST.child = tryBlock_AST!=null &&tryBlock_AST.getFirstChild()!=null ?
        tryBlock_AST.getFirstChild() : tryBlock_AST;
      currentAST.advanceChildToEnd();
    }
    tryBlock_AST = (AST)currentAST.root;
    returnAST = tryBlock_AST;
  }
View Full Code Here

TOP

Related Classes of antlr.ASTPair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.