ntdls / cmathparser Goto Github PK
View Code? Open in Web Editor NEWA fairly robust mathematics parsing engine for C++ projects.
License: MIT License
A fairly robust mathematics parsing engine for C++ projects.
License: MIT License
When trying to compile the code I am receiving Compiler Error C2440
at:
Line 720 in ae5b5fe
Lines 737 to 748 in ae5b5fe
Lines 771 to 776 in ae5b5fe
error C2440: '=': cannot convert from 'const char [2]' to 'char *'
I am using Visual Studio C++20 but I get the same error switching from 20 to 17 or 14 so I am not sure how you are compiling this without any issues. If you have any workarounds for this I will gladly try them out, I just thought I would create this issue incase it's the compiler I am using or maybe some other issue.
Yo, this thing is awesome, just doing some messing around with it now, this could very well be user error, but I found that "sin(pow(10,2))"
gives me this error, but it works the other way round ("pow(sin(10))"
for example), wondering if I'm just missing something or if something wacky is going on with powers in other functions!
Either way this is amazing, looking forward to messing around more with it!
(Edit, I did find a workaround by parsing the string for pow and solving that as a seperate expression!)
This looks super interesting for a OSS project I'm working on (and it looks like nice, clean code). However I need to support variables. Basically I'll have a number of these expressions and some will use expressions or literals to define variables and yet other expressions will use these variables, etc. etc.
Have you thought about supporting that? If not, where would be the best place to inject variable detection and handling in this code?
Hi,
I'm testing the library using expressions containing more than one variable.
These expression for example are causing segmentation fault:
X+X
X+Y
X*X
... and so on
The reason is the following code:
//Get variable value...
if (this->pVariableSetProc!=NULL){
if(!this->pVariableSetProc(this, sVarName, &dVarValue))
{
return this->SetError(ResultInvalidToken, "Variable not defined: %s.", sVarName);
}
} else {
return this->SetError(ResultInvalidToken, "Variable not defined: %s.", sVarName);
}
char sVarValue[64];
//Convert double to string (must be a faster way, but this is just super safe and doesn't create infinite repeating patterns).
//TODO: Fixed percision of 8 on variables seems inflexible.
int iVarValLength = sprintf_s(sVarValue, sizeof(sVarValue), "%.8f", dVarValue);
if (iSourceSz + iVarValLength >= pExp->Allocated)
{
pExp->Allocated = (iSourceSz + iVarValLength) + 1;
pExp->Text = (char*)realloc(pExp->Text, sizeof(char) * pExp->Allocated);
if (!pExp->Text)
{
return this->SetError(ResultMemoryAllocationError, "Memory allocation error.");
}
}
Have you tried to use more than one variable in the expression?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.