Esempio n. 1
0
        /// <summary>
        /// Parse an add or subtract section of an expression.
        /// </summary>
        /// <returns>A node containing the tokenized expression.</returns>
        public Node ParseMultiplyDivide()
        {
            var lhs = ParseUnary();

            while (true)
            {
                OpTypes op;
                switch (_tokenizer.Token)
                {
                case Tokens.Multiply:
                    op = OpTypes.Multiply;
                    break;

                case Tokens.Divide:
                    op = OpTypes.Divide;
                    break;

                default:
                    return(lhs);
                }

                _tokenizer.NextToken();
                lhs = new NodeBinary(lhs, ParseUnary(), op);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Parse an add or subtract section of an expression.
        /// </summary>
        /// <returns>A node containing the tokenized expression.</returns>
        public Node ParseAddSubtract()
        {
            var lhs = ParseMultiplyDivide();

            while (true)
            {
                OpTypes op;
                switch (_tokenizer.Token)
                {
                case Tokens.Add:
                    op = OpTypes.Add;
                    break;

                case Tokens.Subtract:
                    op = OpTypes.Subtract;
                    break;

                default:
                    return(lhs);
                }

                _tokenizer.NextToken();
                lhs = new NodeBinary(lhs, ParseMultiplyDivide(), op);
            }
        }