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; }
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; }