public AST create(int type, String txt, Token first, Token last) { return attachLast(create(type, txt, astFactory.create(first)), last); }
/** Create an AST node with the token type and text passed in, but * with the same background information as another supplied Token (e.g. line numbers). * To be used in place of antlr tree construction syntax, * i.e. #[TOKEN,"text"] becomes create(TOKEN,"text",anotherToken) * * todo - change antlr.ASTFactory to do this instead... */ public AST create(int type, String txt, AST first) { AST t = astFactory.create(type,txt); if ( t != null && first != null) { // first copy details from first token t.initialize(first); // then ensure that type and txt are specific to this new node t.initialize(type,txt); } return t; }
/** Create an AST node with the token type and text passed in, but * with the same background information as another supplied Token (e.g. line numbers) * to be used in place of antlr tree construction syntax, * i.e. #[TOKEN,"text"] becomes create(TOKEN,"text",anotherToken) * * todo - change antlr.ASTFactory to do this instead... */ public AST create(int type, String txt, Token first, Token last) { AST t = astFactory.create(type,txt); if ( t != null && first != null) { // first copy details from first token t.initialize(first); // then ensure that type and txt are specific to this new node t.initialize(type,txt); } if ((t instanceof GroovySourceAST) && last != null) { GroovySourceAST node = (GroovySourceAST)t; node.setLast(last); // This is a good point to call node.setSnippet(), // but it bulks up the AST too much for production code. } return t; }
public final void variableName() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST variableName_AST = null; AST tmp217_AST = null; tmp217_AST = astFactory.create(LT(1)); astFactory.addASTChild(currentAST, tmp217_AST); match(IDENT); variableName_AST = (AST)currentAST.root; returnAST = variableName_AST; }
/** Lookahead to check whether a block begins with explicit closure arguments. */ public final void closableBlockParamsStart() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST closableBlockParamsStart_AST = null; nls(); parameterDeclarationList(); nls(); AST tmp225_AST = null; tmp225_AST = astFactory.create(LT(1)); match(CLOSABLE_BLOCK_OP); returnAST = closableBlockParamsStart_AST; }
/** 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 tmp230_AST = null; tmp230_AST = astFactory.create(LT(1)); astFactory.addASTChild(currentAST, tmp230_AST); match(IDENT); c = LT(1); c_AST = astFactory.create(c); astFactory.makeASTRoot(currentAST, c_AST); match(COLON); if ( inputState.guessing==0 ) { c_AST.setType(LABELED_STAT); } nls(); statementLabelPrefix_AST = (AST)currentAST.root; returnAST = statementLabelPrefix_AST; }
public final void finallyClause() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST finallyClause_AST = null; AST tmp188_AST = null; tmp188_AST = astFactory.create(LT(1)); astFactory.makeASTRoot(currentAST, tmp188_AST); match(LITERAL_finally); compoundStatement(); astFactory.addASTChild(currentAST, returnAST); finallyClause_AST = (AST)currentAST.root; returnAST = finallyClause_AST; }
/** An IDENT token whose spelling is required to start with an uppercase letter. * In the case of a simple statement {UpperID name} the identifier is taken to be a type name, not a command name. */ public final void upperCaseIdent() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST upperCaseIdent_AST = null; if (!(isUpperCase(LT(1)))) throw new SemanticException("isUpperCase(LT(1))"); AST tmp64_AST = null; tmp64_AST = astFactory.create(LT(1)); astFactory.addASTChild(currentAST, tmp64_AST); match(IDENT); upperCaseIdent_AST = (AST)currentAST.root; returnAST = upperCaseIdent_AST; }
/** An assignment operator '=' followed by an expression. (Never empty.) */ public final void varInitializer() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST varInitializer_AST = null; AST tmp43_AST = null; tmp43_AST = astFactory.create(LT(1)); astFactory.makeASTRoot(currentAST, tmp43_AST); match(ASSIGN); nls(); expressionStatementNoCheck(); astFactory.addASTChild(currentAST, returnAST); varInitializer_AST = (AST)currentAST.root; returnAST = varInitializer_AST; }
/** Used to look ahead for a constructor */ public final void constructorStart() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST constructorStart_AST = null; Token id = null; AST id_AST = null; modifiersOpt(); id = LT(1); id_AST = astFactory.create(id); match(IDENT); if (!(isConstructorIdent(id))) throw new SemanticException("isConstructorIdent(id)"); nls(); match(LPAREN); returnAST = constructorStart_AST; }
public final void inclusiveOrExpression() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST inclusiveOrExpression_AST = null; exclusiveOrExpression(); astFactory.addASTChild(currentAST, returnAST); { _loop255: do { if ((LA(1)==BOR)) { AST tmp205_AST = null; tmp205_AST = astFactory.create(LT(1)); astFactory.makeASTRoot(currentAST, tmp205_AST); match(BOR); exclusiveOrExpression(); astFactory.addASTChild(currentAST, returnAST); } else { break _loop255; } } while (true); } inclusiveOrExpression_AST = (AST)currentAST.root; returnAST = inclusiveOrExpression_AST; }
public final void andExpression() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST andExpression_AST = null; equalityExpression(); astFactory.addASTChild(currentAST, returnAST); { _loop261: do { if ((LA(1)==BAND)) { AST tmp207_AST = null; tmp207_AST = astFactory.create(LT(1)); astFactory.makeASTRoot(currentAST, tmp207_AST); match(BAND); equalityExpression(); astFactory.addASTChild(currentAST, returnAST); } else { break _loop261; } } while (true); } andExpression_AST = (AST)currentAST.root; returnAST = andExpression_AST; }
public final void logicalAndExpression() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST logicalAndExpression_AST = null; inclusiveOrExpression(); astFactory.addASTChild(currentAST, returnAST); { _loop252: do { if ((LA(1)==LAND)) { AST tmp204_AST = null; tmp204_AST = astFactory.create(LT(1)); astFactory.makeASTRoot(currentAST, tmp204_AST); match(LAND); inclusiveOrExpression(); astFactory.addASTChild(currentAST, returnAST); } else { break _loop252; } } while (true); } logicalAndExpression_AST = (AST)currentAST.root; returnAST = logicalAndExpression_AST; }
public final void exclusiveOrExpression() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST exclusiveOrExpression_AST = null; andExpression(); astFactory.addASTChild(currentAST, returnAST); { _loop258: do { if ((LA(1)==BXOR)) { AST tmp206_AST = null; tmp206_AST = astFactory.create(LT(1)); astFactory.makeASTRoot(currentAST, tmp206_AST); match(BXOR); andExpression(); astFactory.addASTChild(currentAST, returnAST); } else { break _loop258; } } while (true); } exclusiveOrExpression_AST = (AST)currentAST.root; returnAST = exclusiveOrExpression_AST; }
public final void logicalOrExpression() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST logicalOrExpression_AST = null; logicalAndExpression(); astFactory.addASTChild(currentAST, returnAST); { _loop249: do { if ((LA(1)==LOR)) { AST tmp203_AST = null; tmp203_AST = astFactory.create(LT(1)); astFactory.makeASTRoot(currentAST, tmp203_AST); match(LOR); logicalAndExpression(); astFactory.addASTChild(currentAST, returnAST); } else { break _loop249; } } while (true); } logicalOrExpression_AST = (AST)currentAST.root; returnAST = logicalOrExpression_AST; }
public final void throwsClause() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST throwsClause_AST = null; AST tmp121_AST = null; tmp121_AST = astFactory.create(LT(1)); astFactory.makeASTRoot(currentAST, tmp121_AST); match(LITERAL_throws); identifier(); astFactory.addASTChild(currentAST, returnAST); { _loop173: do { if ((LA(1)==COMMA)) { match(COMMA); identifier(); astFactory.addASTChild(currentAST, returnAST); } else { break _loop173; } } while (true); } throwsClause_AST = (AST)currentAST.root; returnAST = throwsClause_AST; }
lc_AST = astFactory.create(lc); astFactory.makeASTRoot(currentAST, lc_AST); match(LCURLY);
annotations_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(ANNOTATIONS,"ANNOTATIONS")).add(annotations_AST)); currentAST.root = annotations_AST; currentAST.child = annotations_AST!=null &&annotations_AST.getFirstChild()!=null ?
public final void annotationMemberValuePair() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST annotationMemberValuePair_AST = null; Token i = null; AST i_AST = null; AST v_AST = null; Token first = LT(1); i = LT(1); i_AST = astFactory.create(i); match(IDENT); match(ASSIGN); annotationMemberValueInitializer(); v_AST = (AST)returnAST; if ( inputState.guessing==0 ) { annotationMemberValuePair_AST = (AST)currentAST.root; annotationMemberValuePair_AST = (AST)astFactory.make( (new ASTArray(3)).add(create(ANNOTATION_MEMBER_VALUE_PAIR,"ANNOTATION_MEMBER_VALUE_PAIR",first,LT(1))).add(i_AST).add(v_AST)); currentAST.root = annotationMemberValuePair_AST; currentAST.child = annotationMemberValuePair_AST!=null &&annotationMemberValuePair_AST.getFirstChild()!=null ? annotationMemberValuePair_AST.getFirstChild() : annotationMemberValuePair_AST; currentAST.advanceChildToEnd(); } returnAST = annotationMemberValuePair_AST; }
/** Simple names, as in {x|...}, are completely equivalent to {(def x)|...}. Build the right AST. */ public final void closableBlockParam() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST closableBlockParam_AST = null; Token id = null; AST id_AST = null; Token first = LT(1); id = LT(1); id_AST = astFactory.create(id); match(IDENT); if ( inputState.guessing==0 ) { closableBlockParam_AST = (AST)currentAST.root; closableBlockParam_AST = (AST)astFactory.make( (new ASTArray(4)).add(create(PARAMETER_DEF,"PARAMETER_DEF",first,LT(1))).add((AST)astFactory.make( (new ASTArray(1)).add(create(MODIFIERS,"MODIFIERS",first,LT(1))))).add((AST)astFactory.make( (new ASTArray(1)).add(create(TYPE,"TYPE",first,LT(1))))).add(id_AST)); currentAST.root = closableBlockParam_AST; currentAST.child = closableBlockParam_AST!=null &&closableBlockParam_AST.getFirstChild()!=null ? closableBlockParam_AST.getFirstChild() : closableBlockParam_AST; currentAST.advanceChildToEnd(); } returnAST = closableBlockParam_AST; }