Exemple #1
0
        private Node GrabTerm() // определение операций умножение и деление
        {
            Node left = this.GrabFactor();

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

            return(left);
        }
Exemple #2
0
        private Node GrabExpr()  // определение операций сложение и вычитание
        {
            Node left = this.GrabTerm();

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

            return(left);
        }