-
-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When calculating an expression, an error is reported if the expression has [] in it. #337
Comments
Can you post some actual text code to reproduce the problem? |
You're using brackets as parenthesis, which is not supported: (-23)+[1-(-0.3)] should be (-23)+(1-(-0.3)) |
I can understand using parentheses to replace square brackets, e.g. (-23)+(1-(-0.3)), but there are square bracketed expressions in mathematical logic, which can be confusing for the user |
Sample code for example: static void Main(string[] args)
{
var interpreter = new Interpreter();
var parameters = new[] {
new Parameter("CWPT_007_P", 23),
new Parameter("CWPT_007_S", -0.3),
};
var value= interpreter.Eval("(-CWPT_007_P)+[1-(CWPT_007_S+5)]", parameters);
Console.WriteLine($"value: {value}");
} |
I agree with you @landonzeng , but DynamicExpresso is not a math interpreter, the goal is to create a C# interpreter. |
Yes, that's what I was thinking, I had to replace [] with () if I wanted to fulfil a customer request and that was it. |
Error in calculation of (-CWPT_007_P)+[1-(-0.3)]: Expression expected (at index 14).
![image](https://private-user-images.githubusercontent.com/7336781/388450823-5624a32b-c9c0-433e-a5f3-76929956502e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4Njk5NjcsIm5iZiI6MTczOTg2OTY2NywicGF0aCI6Ii83MzM2NzgxLzM4ODQ1MDgyMy01NjI0YTMyYi1jOWMwLTQzM2UtYTVmMy03NjkyOTk1NjUwMmUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMThUMDkwNzQ3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDE0N2I3YTZlZTlkMDgyYmVjYjVhZjE5ODU0NzFhYjYwOWY4MTUyYmJkMjYzNTYyMTFkMDFjNTE1OWZiYzU2ZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.PxXs8YD1HNYErTWIexL3MlytiNLZcc1mLcv17iI3ee8)
![image](https://private-user-images.githubusercontent.com/7336781/388450915-30935da8-53a4-455d-a397-6f795b791f52.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4Njk5NjcsIm5iZiI6MTczOTg2OTY2NywicGF0aCI6Ii83MzM2NzgxLzM4ODQ1MDkxNS0zMDkzNWRhOC01M2E0LTQ1NWQtYTM5Ny02Zjc5NWI3OTFmNTIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMThUMDkwNzQ3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODk2ZTI0MTk5ZmJjODc5ZTEyN2Y1ODIzYzAxYzNkMWZkM2E4Nzc2Y2JjMmRkYTRhOTBkZjYwNzVmYTc5MDNmZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.jKBP0IwgTDWnDxBPIB_agFmPBsBps8wjWbbHUNlR5ik)
![image](https://private-user-images.githubusercontent.com/7336781/388451123-09314af5-46ef-42ec-a6d8-3591aa874f3c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4Njk5NjcsIm5iZiI6MTczOTg2OTY2NywicGF0aCI6Ii83MzM2NzgxLzM4ODQ1MTEyMy0wOTMxNGFmNS00NmVmLTQyZWMtYTZkOC0zNTkxYWE4NzRmM2MucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMThUMDkwNzQ3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjU5NjEwMTIzZDRjYTcyYWIyM2VjMWMxMzI1N2UzZjE1MTNiOTI1ZmUzZWRjYjRkNjVkOTQ4ZGIxNjgwMTgyMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.QJZCKHmggcm_tegCCAa53e8TIV-rjwCG3L8bs286K-E)
The text was updated successfully, but these errors were encountered: