Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }