beltoforion / muparserx

A C++ Library for Parsing Expressions with Strings, Complex Numbers, Vectors, Matrices and more.
http://beltoforion.de/en/muparserx
BSD 2-Clause "Simplified" License
136 stars 60 forks source link

constant starting with letter 'o' #115

Closed lhommev closed 1 year ago

lhommev commented 1 year ago

That doesn't seem to be supported: set constant "organisation" = "whatever"

expression "organisation" evaluation gives : Assertion \"m_nStackPos >= 0\" failed: mpRPN.cpp line 74

lhommev commented 1 year ago

i debugged the code. it looks like 'organisation' is interpreted like 'or' + 'ganisation' 'or' beeing an operator like +abc

Why is the token splited ? there is no syntax delimiter characters ?

beltoforion commented 1 year ago
set constant "organisation" = "whatever" 

is not a valid statement in muparserx syntax.

"organisation"=="foobar"

Does not give an error. Please provide the exact statement that is causing this behavior.

lhommev commented 1 year ago

Hi Beltoforion,

I mean, i 'm using

parser.DefineConst( constant_name , constant_value );

with constant_name "organisation" and constant_value "whatever"

then

string requirement = "organisation == \"foobar\""; parser.SetExpr(requirement); val = parser.Eval();

the Eval command triggers the assertion error.

Not that 'organisation' is not a string. It s a constant/variable name.

lhommev commented 1 year ago

THe use case is that i have multiple requirement strings as a muparserx expression. There is a set of constants that are defined in the parser such as "organisation", "group", "security_level" etc.. I loop over the requirement string and evaluate them. At some point it fails to evaluate.

The same assertion is triggered just by evaluating : "andganisation"

beltoforion commented 1 year ago

Issue is fixed