C# Class CSE.Exps.ArithExp

Used to parse arithmetic expressions
Show file Open project: kcherr1/CSharp-Eval Class Usage Examples

Private Methods

Method Description
Affirm ( CseObject obj ) : CseObject

Applies numeric affirmation (i.e. unary plus) to numeric values

Negate ( CseObject obj ) : CseObject

Applies numeric negation (i.e. unary minus) to numeric values

Parse ( CseObject leftOperand, CseObject rightOperand, ArithType arithType ) : CseObject

Parses arithmetic expressions

Only works with operands that evaluate to either numeric or string types. If both operands are strings and arithType is ADD, concatenation is performed. Else, if either operand is of a float type, both are treated as float type. Else, both are treated as int types. This is to ensure proper behavior of operators such as addition and division. If operands are of int type, result is then parsed as a literal expression to ensure correct return type.