Esempio n. 1
0
        private Expression GrabTerm()
        {
            Expression left = this.GrabFactor();

            while (this.curToken.Type == TokenType.Multiply ||
                   this.curToken.Type == TokenType.Divide)
            {
                Token op = this.curToken;
                this.NextToken();
                Expression right = this.GrabFactor();
                left = new BinOp(op, left, right);
            }

            return(left);
        }
Esempio n. 2
0
        private Expression GrabExpr()
        {
            Expression left = this.GrabTerm();

            while (this.curToken.Type == TokenType.Plus ||
                   this.curToken.Type == TokenType.Minus)
            {
                Token op = this.curToken;
                this.NextToken();
                Expression right = this.GrabTerm();
                left = new BinOp(op, left, right);
            }

            return(left);
        }