예제 #1
0
        private AST NodeFactor(bool isFirstNode)
        {
            AST nodeAST = NodeEntity(isFirstNode);

            while (currentToken.Type == TokenType.MUL || currentToken.Type == TokenType.DIV || currentToken.Type == TokenType.BCMUL || currentToken.Type == TokenType.BCDIV)
            {
                OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken;
                nodeAST = new BinOpAST(nodeAST, binOpToken, NodeEntity(isFirstNode));
            }
            return(nodeAST);
        }
예제 #2
0
        private AST NodeEntity(bool isFirstNode)
        {
            AST nodeAST = Node(isFirstNode);

            while (currentToken.Type == TokenType.CARET || currentToken.Type == TokenType.BCPOW)
            {
                OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken;
                nodeAST = new BinOpAST(nodeAST, binOpToken, Node(isFirstNode));
            }
            return(nodeAST);
        }
예제 #3
0
        private AST NodeExpr(bool isFirstNode)
        {
            AST nodeFactorAST = NodeFactor(isFirstNode);

            while (currentToken.Type == TokenType.PLUS || currentToken.Type == TokenType.MINUS)
            {
                OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken;
                nodeFactorAST = new BinOpAST(nodeFactorAST, binOpToken, NodeFactor(isFirstNode));
            }
            return(nodeFactorAST);
        }
예제 #4
0
        private AST ValueEntity()
        {
            AST valueAST = Value();

            while (currentToken.Type == TokenType.CARET || currentToken.Type == TokenType.BCPOW)
            {
                OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken;
                valueAST = new ValBinOpAST(valueAST, binOpToken, Value());
            }
            return(valueAST);
        }
예제 #5
0
        private AST ValueFactor()
        {
            AST valueAST = ValueEntity();

            while (currentToken.Type == TokenType.MUL || currentToken.Type == TokenType.DIV || currentToken.Type == TokenType.BCMUL || currentToken.Type == TokenType.BCDIV)
            {
                OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken;
                valueAST = new ValBinOpAST(valueAST, binOpToken, ValueEntity());
            }
            return(valueAST);
        }
예제 #6
0
        private AST ValueExpr()
        {
            AST valueFactorAST = ValueFactor();

            while (currentToken.Type == TokenType.PLUS || currentToken.Type == TokenType.MINUS)
            {
                OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken;
                valueFactorAST = new ValBinOpAST(valueFactorAST, binOpToken, ValueFactor());
            }
            return(valueFactorAST);
        }
예제 #7
0
        private ChainAST Chain()
        {
            AST nodeExprAST = NodeExpr(true);

            while (currentToken.Type == TokenType.GOTO)
            {
                OperatorToken gotoToken = (OperatorToken)currentToken;
                Eat(TokenType.GOTO);
                nodeExprAST = new GotoOpAST(nodeExprAST, NodeExpr(false), gotoToken);
            }
            return(new ChainAST(nodeExprAST));
        }