Jan 13, 2012 at 6:53 PM
Edited Jan 13, 2012 at 7:00 PM
Actually, we just pass an String like "2,5 + 1" to be evaluated by NCalc.
The "2,5" is double input that comes from the UI. As mentioned above the coma separator is the decimal value separator in Brazil. So, we expected the "2,5" to be interpreted as Double/Float.
After diving a bit on NCalc source, we realize that the grammar/lexer couldn't parse the value as a Float and throws the following exception:
NCalc.EvaluationException was unhandled
Message=missing EOF at ',' at line 1:1
at NCalc.Expression.Evaluate() in C:\Documents and Settings\kpaixa\My Documents\experimentos\NCalc - Sources\NCalc - Sources\Evaluant.Calculator\Expression.cs:line 197
at NCalc.Play.Program.Main(String args) in C:\Documents and Settings\kpaixa\My Documents\experimentos\NCalc - Sources\NCalc - Sources\Evaluant.Calculator.Play\Program.cs:line 21
In our case, we just replace the comma by a dot before evaluate the expression, but how could we parse that string and identify that numeric value?
Thanks for the attention!
By the way, NCalc is culture invariant indeed! We sent a date value under different cultures on the string expression to be evalutare and it behaved as expected. But the comma separator is breaking it.