示例#1
0
 /*Copy an ASTPair.  Don't call it clone() because we want type-safety */
 public ASTPair copy()
 {
     var tmp = new ASTPair();
     tmp.root = root;
     tmp.child = child;
     return tmp;
 }
示例#2
0
 /// <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();
     }
 }
示例#3
0
        /*Copy an ASTPair.  Don't call it clone() because we want type-safety */
        public ASTPair copy()
        {
            var tmp = new ASTPair();

            tmp.root  = root;
            tmp.child = child;
            return(tmp);
        }
示例#4
0
 /// <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;
     }
 }
        //throws RecognitionException, TokenStreamException
        public void unaryOperator()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode unaryOperator_AST = null;

            try {      // for error handling
            switch ( LA(1) )
            {
            case PLUS:
            {
                Solenoid.Expressions.SerializableNode tmp34_AST = null;
                tmp34_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp34_AST);
                match(PLUS);
                unaryOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case MINUS:
            {
                Solenoid.Expressions.SerializableNode tmp35_AST = null;
                tmp35_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp35_AST);
                match(MINUS);
                unaryOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case BANG:
            {
                Solenoid.Expressions.SerializableNode tmp36_AST = null;
                tmp36_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp36_AST);
                match(BANG);
                unaryOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            default:
            {
                throw new NoViableAltException(LT(1), getFilename());
            }
             }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_0_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = unaryOperator_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void primaryExpression()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode 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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
                primaryExpression_AST = (Solenoid.Expressions.SerializableNode) astFactory.make((AST)(Solenoid.Expressions.SerializableNode) astFactory.create(EXPR,"expression","Solenoid.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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_13_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = primaryExpression_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void function()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode function_AST = null;

            try {      // for error handling
            match(POUND);
            Solenoid.Expressions.FunctionNode tmp80_AST = null;
            tmp80_AST = (Solenoid.Expressions.FunctionNode) astFactory.create(LT(1), "Solenoid.Expressions.FunctionNode");
            astFactory.makeASTRoot(ref currentAST, (AST)tmp80_AST);
            match(ID);
            methodArgs();
            if (0 == inputState.guessing)
            {
                astFactory.addASTChild(ref currentAST, (AST)returnAST);
            }
            function_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_2_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = function_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void exprList()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode 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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
                exprList_AST = (Solenoid.Expressions.SerializableNode) astFactory.make((AST)(Solenoid.Expressions.SerializableNode) astFactory.create(EXPR,"expressionList","Solenoid.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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_2_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = exprList_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void expr()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode expr_AST = null;

            try {      // for error handling
            expression();
            if (0 == inputState.guessing)
            {
                astFactory.addASTChild(ref currentAST, (AST)returnAST);
            }
            match(Token.EOF_TYPE);
            expr_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_0_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = expr_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void constructor()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode constructor_AST = null;
            Solenoid.Expressions.SerializableNode 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 = (Solenoid.Expressions.SerializableNode)returnAST;
                }
                ctorArgs();
                if (0 == inputState.guessing)
                {
                    astFactory.addASTChild(ref currentAST, (AST)returnAST);
                }
                if (0==inputState.guessing)
                {
                    constructor_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                    constructor_AST = (Solenoid.Expressions.SerializableNode) astFactory.make((AST)(Solenoid.Expressions.SerializableNode) astFactory.create(EXPR,type_AST.getText(),"Solenoid.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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            else if ((LA(1)==LITERAL_new) && (LA(2)==ID)) {
                arrayConstructor();
                if (0 == inputState.guessing)
                {
                    astFactory.addASTChild(ref currentAST, (AST)returnAST);
                }
                constructor_AST = (Solenoid.Expressions.SerializableNode)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;
        }
        //throws RecognitionException, TokenStreamException
        public void attribute()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode attribute_AST = null;
            Solenoid.Expressions.SerializableNode tn_AST = null;

            try {      // for error handling
            match(AT);
            match(LBRACKET);
            qualifiedId();
            if (0 == inputState.guessing)
            {
                tn_AST = (Solenoid.Expressions.SerializableNode)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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
                attribute_AST = (Solenoid.Expressions.SerializableNode) astFactory.make((AST)(Solenoid.Expressions.SerializableNode) astFactory.create(EXPR,tn_AST.getText(),"Solenoid.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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_2_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = attribute_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void relationalExpression()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode relationalExpression_AST = null;
            Solenoid.Expressions.SerializableNode e1_AST = null;
            Solenoid.Expressions.SerializableNode op_AST = null;
            Solenoid.Expressions.SerializableNode e2_AST = null;

            try {      // for error handling
            sumExpr();
            if (0 == inputState.guessing)
            {
                e1_AST = (Solenoid.Expressions.SerializableNode)returnAST;
                astFactory.addASTChild(ref currentAST, (AST)returnAST);
            }
            {
                if ((tokenSet_6_.member(LA(1))))
                {
                    relationalOperator();
                    if (0 == inputState.guessing)
                    {
                        op_AST = (Solenoid.Expressions.SerializableNode)returnAST;
                    }
                    sumExpr();
                    if (0 == inputState.guessing)
                    {
                        e2_AST = (Solenoid.Expressions.SerializableNode)returnAST;
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    if (0==inputState.guessing)
                    {
                        relationalExpression_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                        relationalExpression_AST = (Solenoid.Expressions.SerializableNode) astFactory.make((AST)(Solenoid.Expressions.SerializableNode) 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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_7_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = relationalExpression_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void argList()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode argList_AST = null;

            try {      // for error handling
            {
                Solenoid.Expressions.SerializableNode tmp100_AST = null;
                tmp100_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp100_AST);
                match(ID);
                {    // ( ... )*
                    for (;;)
                    {
                        if ((LA(1)==COMMA))
                        {
                            match(COMMA);
                            Solenoid.Expressions.SerializableNode tmp102_AST = null;
                            tmp102_AST = (Solenoid.Expressions.SerializableNode) 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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
                argList_AST = (Solenoid.Expressions.SerializableNode) astFactory.make((AST)(Solenoid.Expressions.SerializableNode) 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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_19_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = argList_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void reference()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode reference_AST = null;
            Solenoid.Expressions.SerializableNode cn_AST = null;
            Solenoid.Expressions.SerializableNode id_AST = null;
            Solenoid.Expressions.SerializableNode 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 = (Solenoid.Expressions.SerializableNode)returnAST;
                }
                match(COLON);
                quotableName();
                if (0 == inputState.guessing)
                {
                    id_AST = (Solenoid.Expressions.SerializableNode)returnAST;
                }
                match(RPAREN);
                if (0==inputState.guessing)
                {
                    reference_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                    reference_AST = (Solenoid.Expressions.SerializableNode) astFactory.make((AST)(Solenoid.Expressions.SerializableNode) 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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            else if ((LA(1)==AT) && (LA(2)==LPAREN)) {
                match(AT);
                match(LPAREN);
                quotableName();
                if (0 == inputState.guessing)
                {
                    localid_AST = (Solenoid.Expressions.SerializableNode)returnAST;
                }
                match(RPAREN);
                if (0==inputState.guessing)
                {
                    reference_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                    reference_AST = (Solenoid.Expressions.SerializableNode) astFactory.make((AST)(Solenoid.Expressions.SerializableNode) 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 = (Solenoid.Expressions.SerializableNode)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;
        }
        //throws RecognitionException, TokenStreamException
        public void quotableName()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode quotableName_AST = null;

            try {      // for error handling
            if ((LA(1)==STRING_LITERAL))
            {
                Solenoid.Expressions.QualifiedIdentifier tmp91_AST = null;
                tmp91_AST = (Solenoid.Expressions.QualifiedIdentifier) astFactory.create(LT(1), "Solenoid.Expressions.QualifiedIdentifier");
                astFactory.makeASTRoot(ref currentAST, (AST)tmp91_AST);
                match(STRING_LITERAL);
                quotableName_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            else if ((LA(1)==ID)) {
                name();
                if (0 == inputState.guessing)
                {
                    astFactory.addASTChild(ref currentAST, (AST)returnAST);
                }
                quotableName_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            else
            {
                throw new NoViableAltException(LT(1), getFilename());
            }

            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_16_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = quotableName_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void qualifiedId()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode qualifiedId_AST = null;

            try {      // for error handling
            Solenoid.Expressions.QualifiedIdentifier tmp94_AST = null;
            tmp94_AST = (Solenoid.Expressions.QualifiedIdentifier) astFactory.create(LT(1), "Solenoid.Expressions.QualifiedIdentifier");
            astFactory.makeASTRoot(ref currentAST, (AST)tmp94_AST);
            match(ID);
            {    // ( ... )*
                for (;;)
                {
                    if ((LA(1)==DOT))
                    {
                        Solenoid.Expressions.SerializableNode tmp95_AST = null;
                        tmp95_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                        astFactory.addASTChild(ref currentAST, (AST)tmp95_AST);
                        match(DOT);
                        Solenoid.Expressions.SerializableNode tmp96_AST = null;
                        tmp96_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                        astFactory.addASTChild(ref currentAST, (AST)tmp96_AST);
                        match(ID);
                    }
                    else
                    {
                        goto _loop114_breakloop;
                    }

                }
            _loop114_breakloop:				;
            }    // ( ... )*
            qualifiedId_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_18_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = qualifiedId_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void property()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode property_AST = null;

            try {      // for error handling
            Solenoid.Expressions.PropertyOrFieldNode tmp90_AST = null;
            tmp90_AST = (Solenoid.Expressions.PropertyOrFieldNode) astFactory.create(LT(1), "Solenoid.Expressions.PropertyOrFieldNode");
            astFactory.addASTChild(ref currentAST, (AST)tmp90_AST);
            match(ID);
            property_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_2_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = property_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void prodExpr()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode prodExpr_AST = null;

            try {      // for error handling
            powExpr();
            if (0 == inputState.guessing)
            {
                astFactory.addASTChild(ref currentAST, (AST)returnAST);
            }
            {    // ( ... )*
                for (;;)
                {
                    if (((LA(1) >= STAR && LA(1) <= MOD)))
                    {
                        {
                            switch ( LA(1) )
                            {
                            case STAR:
                            {
                                Solenoid.Expressions.OpMultiply tmp27_AST = null;
                                tmp27_AST = (Solenoid.Expressions.OpMultiply) astFactory.create(LT(1), "Solenoid.Expressions.OpMultiply");
                                astFactory.makeASTRoot(ref currentAST, (AST)tmp27_AST);
                                match(STAR);
                                break;
                            }
                            case DIV:
                            {
                                Solenoid.Expressions.OpDivide tmp28_AST = null;
                                tmp28_AST = (Solenoid.Expressions.OpDivide) astFactory.create(LT(1), "Solenoid.Expressions.OpDivide");
                                astFactory.makeASTRoot(ref currentAST, (AST)tmp28_AST);
                                match(DIV);
                                break;
                            }
                            case MOD:
                            {
                                Solenoid.Expressions.OpModulous tmp29_AST = null;
                                tmp29_AST = (Solenoid.Expressions.OpModulous) astFactory.create(LT(1), "Solenoid.Expressions.OpModulous");
                                astFactory.makeASTRoot(ref currentAST, (AST)tmp29_AST);
                                match(MOD);
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
                             }
                        }
                        powExpr();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                    else
                    {
                        goto _loop29_breakloop;
                    }

                }
            _loop29_breakloop:				;
            }    // ( ... )*
            prodExpr_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_10_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = prodExpr_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void arrayConstructor()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode arrayConstructor_AST = null;
            Solenoid.Expressions.SerializableNode type_AST = null;

            try {      // for error handling
            match(LITERAL_new);
            qualifiedId();
            if (0 == inputState.guessing)
            {
                type_AST = (Solenoid.Expressions.SerializableNode)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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
                arrayConstructor_AST = (Solenoid.Expressions.SerializableNode) astFactory.make((AST)(Solenoid.Expressions.SerializableNode) astFactory.create(EXPR,type_AST.getText(),"Solenoid.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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_2_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = arrayConstructor_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void arrayRank()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode arrayRank_AST = null;

            try {      // for error handling
            Solenoid.Expressions.SerializableNode tmp104_AST = null;
            tmp104_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
            astFactory.makeASTRoot(ref currentAST, (AST)tmp104_AST);
            match(LBRACKET);
            {
                if ((tokenSet_9_.member(LA(1))))
                {
                    expression();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    {    // ( ... )*
                        for (;;)
                        {
                            if ((LA(1)==COMMA))
                            {
                                match(COMMA);
                                expression();
                                if (0 == inputState.guessing)
                                {
                                    astFactory.addASTChild(ref currentAST, (AST)returnAST);
                                }
                            }
                            else
                            {
                                goto _loop96_breakloop;
                            }

                        }
            _loop96_breakloop:						;
                    }    // ( ... )*
                }
                else if ((LA(1)==RBRACKET)) {
                }
                else
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }

            }
            match(RBRACKET);
            arrayRank_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_20_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = arrayRank_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void relationalOperator()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode relationalOperator_AST = null;

            try {      // for error handling
            switch ( LA(1) )
            {
            case EQUAL:
            {
                Solenoid.Expressions.SerializableNode tmp16_AST = null;
                tmp16_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp16_AST);
                match(EQUAL);
                relationalOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case NOT_EQUAL:
            {
                Solenoid.Expressions.SerializableNode tmp17_AST = null;
                tmp17_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp17_AST);
                match(NOT_EQUAL);
                relationalOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case LESS_THAN:
            {
                Solenoid.Expressions.SerializableNode tmp18_AST = null;
                tmp18_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp18_AST);
                match(LESS_THAN);
                relationalOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case LESS_THAN_OR_EQUAL:
            {
                Solenoid.Expressions.SerializableNode tmp19_AST = null;
                tmp19_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp19_AST);
                match(LESS_THAN_OR_EQUAL);
                relationalOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case GREATER_THAN:
            {
                Solenoid.Expressions.SerializableNode tmp20_AST = null;
                tmp20_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp20_AST);
                match(GREATER_THAN);
                relationalOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case GREATER_THAN_OR_EQUAL:
            {
                Solenoid.Expressions.SerializableNode tmp21_AST = null;
                tmp21_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp21_AST);
                match(GREATER_THAN_OR_EQUAL);
                relationalOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case IN:
            {
                Solenoid.Expressions.SerializableNode tmp22_AST = null;
                tmp22_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp22_AST);
                match(IN);
                relationalOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case IS:
            {
                Solenoid.Expressions.SerializableNode tmp23_AST = null;
                tmp23_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp23_AST);
                match(IS);
                relationalOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case BETWEEN:
            {
                Solenoid.Expressions.SerializableNode tmp24_AST = null;
                tmp24_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp24_AST);
                match(BETWEEN);
                relationalOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case LIKE:
            {
                Solenoid.Expressions.SerializableNode tmp25_AST = null;
                tmp25_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp25_AST);
                match(LIKE);
                relationalOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            case MATCHES:
            {
                Solenoid.Expressions.SerializableNode tmp26_AST = null;
                tmp26_AST = (Solenoid.Expressions.SerializableNode) astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, (AST)tmp26_AST);
                match(MATCHES);
                relationalOperator_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                break;
            }
            default:
            {
                throw new NoViableAltException(LT(1), getFilename());
            }
             }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_9_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = relationalOperator_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void boolLiteral()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode boolLiteral_AST = null;

            try {      // for error handling
            if ((LA(1)==TRUE))
            {
                Solenoid.Expressions.BooleanLiteralNode tmp110_AST = null;
                tmp110_AST = (Solenoid.Expressions.BooleanLiteralNode) astFactory.create(LT(1), "Solenoid.Expressions.BooleanLiteralNode");
                astFactory.addASTChild(ref currentAST, (AST)tmp110_AST);
                match(TRUE);
                boolLiteral_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            else if ((LA(1)==FALSE)) {
                Solenoid.Expressions.BooleanLiteralNode tmp111_AST = null;
                tmp111_AST = (Solenoid.Expressions.BooleanLiteralNode) astFactory.create(LT(1), "Solenoid.Expressions.BooleanLiteralNode");
                astFactory.addASTChild(ref currentAST, (AST)tmp111_AST);
                match(FALSE);
                boolLiteral_AST = (Solenoid.Expressions.SerializableNode)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 = boolLiteral_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void selection()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode selection_AST = null;

            try {      // for error handling
            Solenoid.Expressions.SelectionNode tmp59_AST = null;
            tmp59_AST = (Solenoid.Expressions.SelectionNode) astFactory.create(LT(1), "Solenoid.Expressions.SelectionNode");
            astFactory.makeASTRoot(ref currentAST, (AST)tmp59_AST);
            match(SELECT);
            expression();
            if (0 == inputState.guessing)
            {
                astFactory.addASTChild(ref currentAST, (AST)returnAST);
            }
            {    // ( ... )*
                for (;;)
                {
                    if ((LA(1)==COMMA))
                    {
                        match(COMMA);
                        expression();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                    else
                    {
                        goto _loop71_breakloop;
                    }

                }
            _loop71_breakloop:				;
            }    // ( ... )*
            match(RCURLY);
            selection_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_2_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = selection_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void ctorArgs()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode ctorArgs_AST = null;

            try {      // for error handling
            match(LPAREN);
            {
                if ((tokenSet_9_.member(LA(1))))
                {
                    namedArgument();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    {    // ( ... )*
                        for (;;)
                        {
                            if ((LA(1)==COMMA))
                            {
                                match(COMMA);
                                namedArgument();
                                if (0 == inputState.guessing)
                                {
                                    astFactory.addASTChild(ref currentAST, (AST)returnAST);
                                }
                            }
                            else
                            {
                                goto _loop107_breakloop;
                            }

                        }
            _loop107_breakloop:						;
                    }    // ( ... )*
                }
                else if ((LA(1)==RPAREN)) {
                }
                else
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }

            }
            match(RPAREN);
            ctorArgs_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_2_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = ctorArgs_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void startNode()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode startNode_AST = null;

            try {      // for error handling
            {
                switch ( LA(1) )
                {
                case ID:
                {
                    methodOrProperty();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                case DOLLAR:
                {
                    localFunctionOrVar();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                case LBRACKET:
                {
                    indexer();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                case FALSE:
                case TRUE:
                case NULL_LITERAL:
                case STRING_LITERAL:
                case INTEGER_LITERAL:
                case HEXADECIMAL_INTEGER_LITERAL:
                case REAL_LITERAL:
                {
                    literal();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                case TYPE:
                {
                    type();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                case LITERAL_new:
                {
                    constructor();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                case PROJECT:
                {
                    projection();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                case SELECT:
                {
                    selection();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                case SELECT_FIRST:
                {
                    firstSelection();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                case SELECT_LAST:
                {
                    lastSelection();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                case LCURLY:
                {
                    listInitializer();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                case LAMBDA:
                {
                    lambda();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                    break;
                }
                default:
                    bool synPredMatched40 = false;
                    if (((LA(1)==LPAREN) && (tokenSet_9_.member(LA(2)))))
                    {
                        int _m40 = mark();
                        synPredMatched40 = true;
                        inputState.guessing++;
                        try {
                            {
                                match(LPAREN);
                                expression();
                                match(SEMI);
                            }
                        }
                        catch (RecognitionException)
                        {
                            synPredMatched40 = false;
                        }
                        rewind(_m40);
                        inputState.guessing--;
                    }
                    if ( synPredMatched40 )
                    {
                        exprList();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                    else if ((LA(1)==LPAREN) && (tokenSet_9_.member(LA(2)))) {
                        parenExpr();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                    else if ((LA(1)==POUND) && (LA(2)==ID)) {
                        functionOrVar();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                    else if ((LA(1)==AT) && (LA(2)==LPAREN)) {
                        reference();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                    else if ((LA(1)==POUND) && (LA(2)==LCURLY)) {
                        mapInitializer();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                    else if ((LA(1)==AT) && (LA(2)==LBRACKET)) {
                        attribute();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                else
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                break; }
            }
            startNode_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_2_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = startNode_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void expression()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode expression_AST = null;

            try {      // for error handling
            logicalOrExpression();
            if (0 == inputState.guessing)
            {
                astFactory.addASTChild(ref currentAST, (AST)returnAST);
            }
            {
                switch ( LA(1) )
                {
                case ASSIGN:
                {
                    {
                        Solenoid.Expressions.AssignNode tmp2_AST = null;
                        tmp2_AST = (Solenoid.Expressions.AssignNode) astFactory.create(LT(1), "Solenoid.Expressions.AssignNode");
                        astFactory.makeASTRoot(ref currentAST, (AST)tmp2_AST);
                        match(ASSIGN);
                        logicalOrExpression();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                    break;
                }
                case DEFAULT:
                {
                    {
                        Solenoid.Expressions.DefaultNode tmp3_AST = null;
                        tmp3_AST = (Solenoid.Expressions.DefaultNode) astFactory.create(LT(1), "Solenoid.Expressions.DefaultNode");
                        astFactory.makeASTRoot(ref currentAST, (AST)tmp3_AST);
                        match(DEFAULT);
                        logicalOrExpression();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                    break;
                }
                case QMARK:
                {
                    {
                        Solenoid.Expressions.TernaryNode tmp4_AST = null;
                        tmp4_AST = (Solenoid.Expressions.TernaryNode) astFactory.create(LT(1), "Solenoid.Expressions.TernaryNode");
                        astFactory.makeASTRoot(ref currentAST, (AST)tmp4_AST);
                        match(QMARK);
                        expression();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                        match(COLON);
                        expression();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                    break;
                }
                case EOF:
                case SEMI:
                case RPAREN:
                case COLON:
                case COMMA:
                case RBRACKET:
                case RCURLY:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            expression_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_1_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = expression_AST;
        }
示例#27
0
 /// <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();
     }
 }
        //throws RecognitionException, TokenStreamException
        public void firstSelection()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode firstSelection_AST = null;

            try {      // for error handling
            Solenoid.Expressions.SelectionFirstNode tmp62_AST = null;
            tmp62_AST = (Solenoid.Expressions.SelectionFirstNode) astFactory.create(LT(1), "Solenoid.Expressions.SelectionFirstNode");
            astFactory.makeASTRoot(ref currentAST, (AST)tmp62_AST);
            match(SELECT_FIRST);
            expression();
            if (0 == inputState.guessing)
            {
                astFactory.addASTChild(ref currentAST, (AST)returnAST);
            }
            match(RCURLY);
            firstSelection_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_2_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = firstSelection_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void unaryExpression()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode unaryExpression_AST = null;

            try {      // for error handling
            if ((LA(1)==PLUS||LA(1)==MINUS||LA(1)==BANG))
            {
                {
                    switch ( LA(1) )
                    {
                    case PLUS:
                    {
                        Solenoid.Expressions.OpUnaryPlus tmp31_AST = null;
                        tmp31_AST = (Solenoid.Expressions.OpUnaryPlus) astFactory.create(LT(1), "Solenoid.Expressions.OpUnaryPlus");
                        astFactory.makeASTRoot(ref currentAST, (AST)tmp31_AST);
                        match(PLUS);
                        break;
                    }
                    case MINUS:
                    {
                        Solenoid.Expressions.OpUnaryMinus tmp32_AST = null;
                        tmp32_AST = (Solenoid.Expressions.OpUnaryMinus) astFactory.create(LT(1), "Solenoid.Expressions.OpUnaryMinus");
                        astFactory.makeASTRoot(ref currentAST, (AST)tmp32_AST);
                        match(MINUS);
                        break;
                    }
                    case BANG:
                    {
                        Solenoid.Expressions.OpNot tmp33_AST = null;
                        tmp33_AST = (Solenoid.Expressions.OpNot) astFactory.create(LT(1), "Solenoid.Expressions.OpNot");
                        astFactory.makeASTRoot(ref currentAST, (AST)tmp33_AST);
                        match(BANG);
                        break;
                    }
                    default:
                    {
                        throw new NoViableAltException(LT(1), getFilename());
                    }
                     }
                }
                unaryExpression();
                if (0 == inputState.guessing)
                {
                    astFactory.addASTChild(ref currentAST, (AST)returnAST);
                }
                unaryExpression_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            else if ((tokenSet_12_.member(LA(1)))) {
                primaryExpression();
                if (0 == inputState.guessing)
                {
                    astFactory.addASTChild(ref currentAST, (AST)returnAST);
                }
                unaryExpression_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            else
            {
                throw new NoViableAltException(LT(1), getFilename());
            }

            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_13_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = unaryExpression_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void sumExpr()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode sumExpr_AST = null;

            try {      // for error handling
            prodExpr();
            if (0 == inputState.guessing)
            {
                astFactory.addASTChild(ref currentAST, (AST)returnAST);
            }
            {    // ( ... )*
                for (;;)
                {
                    if ((LA(1)==PLUS||LA(1)==MINUS))
                    {
                        {
                            if ((LA(1)==PLUS))
                            {
                                Solenoid.Expressions.OpAdd tmp14_AST = null;
                                tmp14_AST = (Solenoid.Expressions.OpAdd) astFactory.create(LT(1), "Solenoid.Expressions.OpAdd");
                                astFactory.makeASTRoot(ref currentAST, (AST)tmp14_AST);
                                match(PLUS);
                            }
                            else if ((LA(1)==MINUS)) {
                                Solenoid.Expressions.OpSubtract tmp15_AST = null;
                                tmp15_AST = (Solenoid.Expressions.OpSubtract) astFactory.create(LT(1), "Solenoid.Expressions.OpSubtract");
                                astFactory.makeASTRoot(ref currentAST, (AST)tmp15_AST);
                                match(MINUS);
                            }
                            else
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }

                        }
                        prodExpr();
                        if (0 == inputState.guessing)
                        {
                            astFactory.addASTChild(ref currentAST, (AST)returnAST);
                        }
                    }
                    else
                    {
                        goto _loop25_breakloop;
                    }

                }
            _loop25_breakloop:				;
            }    // ( ... )*
            sumExpr_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_8_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = sumExpr_AST;
        }
        //throws RecognitionException, TokenStreamException
        public void powExpr()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode powExpr_AST = null;

            try {      // for error handling
            unaryExpression();
            if (0 == inputState.guessing)
            {
                astFactory.addASTChild(ref currentAST, (AST)returnAST);
            }
            {
                if ((LA(1)==POWER))
                {
                    Solenoid.Expressions.OpPower tmp30_AST = null;
                    tmp30_AST = (Solenoid.Expressions.OpPower) astFactory.create(LT(1), "Solenoid.Expressions.OpPower");
                    astFactory.makeASTRoot(ref currentAST, (AST)tmp30_AST);
                    match(POWER);
                    unaryExpression();
                    if (0 == inputState.guessing)
                    {
                        astFactory.addASTChild(ref currentAST, (AST)returnAST);
                    }
                }
                else if ((tokenSet_11_.member(LA(1)))) {
                }
                else
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }

            }
            powExpr_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_11_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = powExpr_AST;
        }
示例#32
0
 /// <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;
     }
 }
        //throws RecognitionException, TokenStreamException
        public void type()
        {
            returnAST = null;
            ASTPair currentAST = new ASTPair();
            Solenoid.Expressions.SerializableNode type_AST = null;
            Solenoid.Expressions.SerializableNode tn_AST = null;

            try {      // for error handling
            match(TYPE);
            name();
            if (0 == inputState.guessing)
            {
                tn_AST = (Solenoid.Expressions.SerializableNode)returnAST;
            }
            match(RPAREN);
            if (0==inputState.guessing)
            {
                type_AST = (Solenoid.Expressions.SerializableNode)currentAST.root;
                type_AST = (Solenoid.Expressions.SerializableNode) astFactory.make((AST)(Solenoid.Expressions.SerializableNode) astFactory.create(EXPR,tn_AST.getText(),"Solenoid.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 = (Solenoid.Expressions.SerializableNode)currentAST.root;
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_2_);
            }
            else
            {
                throw ex;
            }
            }
            returnAST = type_AST;
        }