/// <summary> /// Add a child to the current AST /// </summary> /// <param name="currentAST">The AST to add a child to</param> /// <param name="child">The child AST to be added</param> public virtual void addASTChild(ref ASTPair currentAST, AST child) { if (child != null) { if (currentAST.root == null) { // Make new child the current root currentAST.root = child; } else { if (currentAST.child == null) { // Add new child to current root currentAST.root.setFirstChild(child); } else { currentAST.child.setNextSibling(child); } } // Make new child the current child currentAST.child = child; currentAST.advanceChildToEnd(); } }
/// <summary> /// Make an AST the root of current AST. /// </summary> /// <param name="currentAST"></param> /// <param name="root"></param> public virtual void makeASTRoot(ref ASTPair currentAST, AST root) { if (root != null) { // Add the current root as a child of new root root.addChild(currentAST.root); // The new current child is the last sibling of the old root currentAST.child = currentAST.root; currentAST.advanceChildToEnd(); // Set the new root currentAST.root = root; } }
public void mapEntry() //throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); Spring.Expressions.SpringAST mapEntry_AST = null; try { // for error handling expression(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } match(COLON); expression(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } if (0==inputState.guessing) { mapEntry_AST = (Spring.Expressions.SpringAST)currentAST.root; mapEntry_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,"entry","Spring.Expressions.MapEntryNode"), (AST)mapEntry_AST); currentAST.root = mapEntry_AST; if ( (null != mapEntry_AST) && (null != mapEntry_AST.getFirstChild()) ) currentAST.child = mapEntry_AST.getFirstChild(); else currentAST.child = mapEntry_AST; currentAST.advanceChildToEnd(); } mapEntry_AST = (Spring.Expressions.SpringAST)currentAST.root; } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_21_); } else { throw ex; } } returnAST = mapEntry_AST; }
public void relationalExpression() //throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); Spring.Expressions.SpringAST relationalExpression_AST = null; Spring.Expressions.SpringAST e1_AST = null; Spring.Expressions.SpringAST op_AST = null; Spring.Expressions.SpringAST e2_AST = null; try { // for error handling sumExpr(); if (0 == inputState.guessing) { e1_AST = (Spring.Expressions.SpringAST)returnAST; astFactory.addASTChild(ref currentAST, (AST)returnAST); } { if ((tokenSet_6_.member(LA(1)))) { relationalOperator(); if (0 == inputState.guessing) { op_AST = (Spring.Expressions.SpringAST)returnAST; } sumExpr(); if (0 == inputState.guessing) { e2_AST = (Spring.Expressions.SpringAST)returnAST; astFactory.addASTChild(ref currentAST, (AST)returnAST); } if (0==inputState.guessing) { relationalExpression_AST = (Spring.Expressions.SpringAST)currentAST.root; relationalExpression_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,op_AST.getText(),GetRelationalOperatorNodeType(op_AST.getText())), (AST)relationalExpression_AST); currentAST.root = relationalExpression_AST; if ( (null != relationalExpression_AST) && (null != relationalExpression_AST.getFirstChild()) ) currentAST.child = relationalExpression_AST.getFirstChild(); else currentAST.child = relationalExpression_AST; currentAST.advanceChildToEnd(); } } else if ((tokenSet_7_.member(LA(1)))) { } else { throw new NoViableAltException(LT(1), getFilename()); } } relationalExpression_AST = (Spring.Expressions.SpringAST)currentAST.root; } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_7_); } else { throw ex; } } returnAST = relationalExpression_AST; }
public void exprList() //throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); Spring.Expressions.SpringAST exprList_AST = null; try { // for error handling match(LPAREN); expression(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } { // ( ... )+ int _cnt4=0; for (;;) { if ((LA(1)==SEMI)) { match(SEMI); expression(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } } else { if (_cnt4 >= 1) { goto _loop4_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; } } _cnt4++; } _loop4_breakloop: ; } // ( ... )+ match(RPAREN); if (0==inputState.guessing) { exprList_AST = (Spring.Expressions.SpringAST)currentAST.root; exprList_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,"expressionList","Spring.Expressions.ExpressionListNode"), (AST)exprList_AST); currentAST.root = exprList_AST; if ( (null != exprList_AST) && (null != exprList_AST.getFirstChild()) ) currentAST.child = exprList_AST.getFirstChild(); else currentAST.child = exprList_AST; currentAST.advanceChildToEnd(); } exprList_AST = (Spring.Expressions.SpringAST)currentAST.root; } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_2_); } else { throw ex; } } returnAST = exprList_AST; }
public void arrayConstructor() //throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); Spring.Expressions.SpringAST arrayConstructor_AST = null; Spring.Expressions.SpringAST type_AST = null; try { // for error handling match(LITERAL_new); qualifiedId(); if (0 == inputState.guessing) { type_AST = (Spring.Expressions.SpringAST)returnAST; } arrayRank(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } { if ((LA(1)==LCURLY)) { listInitializer(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } } else if ((tokenSet_2_.member(LA(1)))) { } else { throw new NoViableAltException(LT(1), getFilename()); } } if (0==inputState.guessing) { arrayConstructor_AST = (Spring.Expressions.SpringAST)currentAST.root; arrayConstructor_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,type_AST.getText(),"Spring.Expressions.ArrayConstructorNode"), (AST)arrayConstructor_AST); currentAST.root = arrayConstructor_AST; if ( (null != arrayConstructor_AST) && (null != arrayConstructor_AST.getFirstChild()) ) currentAST.child = arrayConstructor_AST.getFirstChild(); else currentAST.child = arrayConstructor_AST; currentAST.advanceChildToEnd(); } arrayConstructor_AST = (Spring.Expressions.SpringAST)currentAST.root; } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_2_); } else { throw ex; } } returnAST = arrayConstructor_AST; }
public void attribute() //throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); Spring.Expressions.SpringAST attribute_AST = null; Spring.Expressions.SpringAST tn_AST = null; try { // for error handling match(AT); match(LBRACKET); qualifiedId(); if (0 == inputState.guessing) { tn_AST = (Spring.Expressions.SpringAST)returnAST; } { if ((LA(1)==LPAREN)) { ctorArgs(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } } else if ((LA(1)==RBRACKET)) { } else { throw new NoViableAltException(LT(1), getFilename()); } } match(RBRACKET); if (0==inputState.guessing) { attribute_AST = (Spring.Expressions.SpringAST)currentAST.root; attribute_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,tn_AST.getText(),"Spring.Expressions.AttributeNode"), (AST)attribute_AST); currentAST.root = attribute_AST; if ( (null != attribute_AST) && (null != attribute_AST.getFirstChild()) ) currentAST.child = attribute_AST.getFirstChild(); else currentAST.child = attribute_AST; currentAST.advanceChildToEnd(); } attribute_AST = (Spring.Expressions.SpringAST)currentAST.root; } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_2_); } else { throw ex; } } returnAST = attribute_AST; }
public void argList() //throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); Spring.Expressions.SpringAST argList_AST = null; try { // for error handling { Spring.Expressions.SpringAST tmp100_AST = null; tmp100_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); astFactory.addASTChild(ref currentAST, (AST)tmp100_AST); match(ID); { // ( ... )* for (;;) { if ((LA(1)==COMMA)) { match(COMMA); Spring.Expressions.SpringAST tmp102_AST = null; tmp102_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); astFactory.addASTChild(ref currentAST, (AST)tmp102_AST); match(ID); } else { goto _loop87_breakloop; } } _loop87_breakloop: ; } // ( ... )* } if (0==inputState.guessing) { argList_AST = (Spring.Expressions.SpringAST)currentAST.root; argList_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,"args"), (AST)argList_AST); currentAST.root = argList_AST; if ( (null != argList_AST) && (null != argList_AST.getFirstChild()) ) currentAST.child = argList_AST.getFirstChild(); else currentAST.child = argList_AST; currentAST.advanceChildToEnd(); } argList_AST = (Spring.Expressions.SpringAST)currentAST.root; } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_19_); } else { throw ex; } } returnAST = argList_AST; }
public void lambda() //throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); Spring.Expressions.SpringAST lambda_AST = null; try { // for error handling match(LAMBDA); { if ((LA(1)==ID)) { argList(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } } else if ((LA(1)==PIPE)) { } else { throw new NoViableAltException(LT(1), getFilename()); } } match(PIPE); expression(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } match(RCURLY); if (0==inputState.guessing) { lambda_AST = (Spring.Expressions.SpringAST)currentAST.root; lambda_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,"lambda","Spring.Expressions.LambdaExpressionNode"), (AST)lambda_AST); currentAST.root = lambda_AST; if ( (null != lambda_AST) && (null != lambda_AST.getFirstChild()) ) currentAST.child = lambda_AST.getFirstChild(); else currentAST.child = lambda_AST; currentAST.advanceChildToEnd(); } lambda_AST = (Spring.Expressions.SpringAST)currentAST.root; } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_2_); } else { throw ex; } } returnAST = lambda_AST; }
public void constructor() //throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); Spring.Expressions.SpringAST constructor_AST = null; Spring.Expressions.SpringAST type_AST = null; try { // for error handling bool synPredMatched90 = false; if (((LA(1)==LITERAL_new) && (LA(2)==ID))) { int _m90 = mark(); synPredMatched90 = true; inputState.guessing++; try { { match(LITERAL_new); qualifiedId(); match(LPAREN); } } catch (RecognitionException) { synPredMatched90 = false; } rewind(_m90); inputState.guessing--; } if ( synPredMatched90 ) { match(LITERAL_new); qualifiedId(); if (0 == inputState.guessing) { type_AST = (Spring.Expressions.SpringAST)returnAST; } ctorArgs(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } if (0==inputState.guessing) { constructor_AST = (Spring.Expressions.SpringAST)currentAST.root; constructor_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,type_AST.getText(),"Spring.Expressions.ConstructorNode"), (AST)constructor_AST); currentAST.root = constructor_AST; if ( (null != constructor_AST) && (null != constructor_AST.getFirstChild()) ) currentAST.child = constructor_AST.getFirstChild(); else currentAST.child = constructor_AST; currentAST.advanceChildToEnd(); } constructor_AST = (Spring.Expressions.SpringAST)currentAST.root; } else if ((LA(1)==LITERAL_new) && (LA(2)==ID)) { arrayConstructor(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } constructor_AST = (Spring.Expressions.SpringAST)currentAST.root; } else { throw new NoViableAltException(LT(1), getFilename()); } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_2_); } else { throw ex; } } returnAST = constructor_AST; }
public void type() //throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); Spring.Expressions.SpringAST type_AST = null; Spring.Expressions.SpringAST tn_AST = null; try { // for error handling match(TYPE); name(); if (0 == inputState.guessing) { tn_AST = (Spring.Expressions.SpringAST)returnAST; } match(RPAREN); if (0==inputState.guessing) { type_AST = (Spring.Expressions.SpringAST)currentAST.root; type_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,tn_AST.getText(),"Spring.Expressions.TypeNode"), (AST)type_AST); currentAST.root = type_AST; if ( (null != type_AST) && (null != type_AST.getFirstChild()) ) currentAST.child = type_AST.getFirstChild(); else currentAST.child = type_AST; currentAST.advanceChildToEnd(); } type_AST = (Spring.Expressions.SpringAST)currentAST.root; } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_2_); } else { throw ex; } } returnAST = type_AST; }
public void reference() //throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); Spring.Expressions.SpringAST reference_AST = null; Spring.Expressions.SpringAST cn_AST = null; Spring.Expressions.SpringAST id_AST = null; Spring.Expressions.SpringAST localid_AST = null; try { // for error handling bool synPredMatched64 = false; if (((LA(1)==AT) && (LA(2)==LPAREN))) { int _m64 = mark(); synPredMatched64 = true; inputState.guessing++; try { { match(AT); match(LPAREN); quotableName(); match(COLON); } } catch (RecognitionException) { synPredMatched64 = false; } rewind(_m64); inputState.guessing--; } if ( synPredMatched64 ) { match(AT); match(LPAREN); quotableName(); if (0 == inputState.guessing) { cn_AST = (Spring.Expressions.SpringAST)returnAST; } match(COLON); quotableName(); if (0 == inputState.guessing) { id_AST = (Spring.Expressions.SpringAST)returnAST; } match(RPAREN); if (0==inputState.guessing) { reference_AST = (Spring.Expressions.SpringAST)currentAST.root; reference_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,"ref","Spring.Context.Support.ReferenceNode"), (AST)cn_AST, (AST)id_AST); currentAST.root = reference_AST; if ( (null != reference_AST) && (null != reference_AST.getFirstChild()) ) currentAST.child = reference_AST.getFirstChild(); else currentAST.child = reference_AST; currentAST.advanceChildToEnd(); } reference_AST = (Spring.Expressions.SpringAST)currentAST.root; } else if ((LA(1)==AT) && (LA(2)==LPAREN)) { match(AT); match(LPAREN); quotableName(); if (0 == inputState.guessing) { localid_AST = (Spring.Expressions.SpringAST)returnAST; } match(RPAREN); if (0==inputState.guessing) { reference_AST = (Spring.Expressions.SpringAST)currentAST.root; reference_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,"ref","Spring.Context.Support.ReferenceNode"), (AST)null, (AST)localid_AST); currentAST.root = reference_AST; if ( (null != reference_AST) && (null != reference_AST.getFirstChild()) ) currentAST.child = reference_AST.getFirstChild(); else currentAST.child = reference_AST; currentAST.advanceChildToEnd(); } reference_AST = (Spring.Expressions.SpringAST)currentAST.root; } else { throw new NoViableAltException(LT(1), getFilename()); } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_2_); } else { throw ex; } } returnAST = reference_AST; }
public void primaryExpression() //throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); Spring.Expressions.SpringAST primaryExpression_AST = null; try { // for error handling startNode(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } { if ((tokenSet_14_.member(LA(1)))) { node(); if (0 == inputState.guessing) { astFactory.addASTChild(ref currentAST, (AST)returnAST); } } else if ((tokenSet_13_.member(LA(1)))) { } else { throw new NoViableAltException(LT(1), getFilename()); } } if (0==inputState.guessing) { primaryExpression_AST = (Spring.Expressions.SpringAST)currentAST.root; primaryExpression_AST = (Spring.Expressions.SpringAST) astFactory.make((AST)(Spring.Expressions.SpringAST) astFactory.create(EXPR,"expression","Spring.Expressions.Expression"), (AST)primaryExpression_AST); currentAST.root = primaryExpression_AST; if ( (null != primaryExpression_AST) && (null != primaryExpression_AST.getFirstChild()) ) currentAST.child = primaryExpression_AST.getFirstChild(); else currentAST.child = primaryExpression_AST; currentAST.advanceChildToEnd(); } primaryExpression_AST = (Spring.Expressions.SpringAST)currentAST.root; } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_13_); } else { throw ex; } } returnAST = primaryExpression_AST; }