0

While using Flee I got this exception message "SyntaxError: Unexpected character: I Line: 1, Column: 1" when I am trying to use I character in my expression string.

ExpressionContext EC = new ExpressionContext();  

EC.Variables.Add("I", 1);
EC.Variables.Add("b", 4);
EC.Variables.Add("p", new Point(0, 0, 0));

string exp = "I > b";

IDynamicExpression DE = EC.CompileDynamic(exp);

bool o = (bool)DE.Evaluate();

//SyntaxError: Unexpected character: I Line: 1, Column: 1

Same thing happens with "POINT.X > 0" as well.

auselen
  • 27,577
  • 7
  • 73
  • 114
tolga güler
  • 308
  • 1
  • 7

2 Answers2

0

"I" character has a problem, but you can replace your formula and variables with "i" and it works.

.Replace("I", "i")
Serdar
  • 1,416
  • 2
  • 17
  • 43
0

I think your mean "POINT.X >" 0 POINT.X is the variable name, so flee has a limitation with the non-alphanumeric character in the variables names, the only accepted is the underscore "_". This is something maybe we could collaborate and solve over the flee project, so yo could try creating a expression languages to remove non-alphanumeric characters or create a mapping replacing by another tokens:

i.e "." => "___Dot____", "-" => "___Dash____" and so on.

Using a regex like Regex.Replace(Variable, "[^a-bA-B0-9_]+", nonAlphaNumeric=> Mapper[nonAlphaNumeric.value]). Mapper could be a dictionary or whatever you decide.