예제 #1
0
        private Expression ReadTerm( Expression parent )
        {
            Expression factor = ReadFactor( parent );

            if ( Tokenizer.IsNextToken( "*", "/", "%", "^" ) )
            {
                OperatorExpression result = new OperatorExpression( parent );
                result.Left = factor;

                result.Operator = CurrentToken;
                ReadNextToken();

                result.Right = ReadExpression( parent );

                return result;
            }
            else
                return factor;
        }
예제 #2
0
        private Expression ReadExpression( Expression parent )
        {
            Expression term = ReadTerm( parent );

            if ( Tokenizer.IsNextToken( "+", "-" ) )
            {
                OperatorExpression result = new OperatorExpression( parent );
                result.Left = term;

                result.Operator = CurrentToken;
                ReadNextToken();

                result.Right = ReadExpression( parent );

                return result;
            }
            else
                return term;
        }