-
Notifications
You must be signed in to change notification settings - Fork 37
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
Suppress conversion into e function #61
Comments
Hi @S-Man42 this sounds like a bug in the parser. The only allowed syntax should either |
Hi, any news on this? :) |
Hi, |
Still having this issue :( |
Interesting. I still have this issue. I will have a deep dive into my code and let you now asap |
Yes, I can totally reproduce it with math_expressions 2.6.0 Here is a screenshot from my app. As you can see "8A" is not giving anything, whereas "8E" gives a result. However, I lowerCase the input before I put it into your library. Does this make a difference? I checked the point in the code where I call your library (https://github.com/GCWizard/GCWizard/blob/c3bb2ed1060584698cd5557646951ac3b4420644/lib/tools/formula_solver/logic/formula_parser.dart#L472): The
Stepping into your code definitely shows that the parser finds a |
Thanks for the additional detail. Based on your sample code I was able to reproduce this as well with the lowercase version of the expression ( |
Hi @S-Man42, I've uploaded a pre-release version You'll have to change the instantiation of the parser as follows to make use of the new implementation: // math-expressions v2.6.0
Parser parser = Parser(); // math-expressions v2.7.0-rc.1
ExpressionParser parser = GrammarParser(); It should be fully backwards compatible except for some minor features that I haven't finished yet (implicit multiplication, and parsing of n-th root function). |
I'll check asap. However, we cannot use it atm if nth root is not working. Since our tool documented the nrt formula we need to wait for its implementation to provide full backwards compatibility. Can you estimate its implementation? |
@S-Man42 I've now published Another caveat I realised is that variable/function naming is more restrictive in the new parser implementation. The allowed pattern for identifiers is: Starting with a letter or If that's an issue for you I'll consider some alternative options. |
Hi, thanks for your. However I don't get it running because I have a dependency version conflict between your embedded
However, for testing purposes and giving you some feedback, I did a dependency override. Ok, well. I recognized some failing tests now in my engine:
The second and the fifth case give an error now. |
@S-Man42 Thanks for testing this release! The dependency conflict is a about a transitive dependency of
Sorry, no ETA on these as I only am able to work on this library in my spare time. |
I am not quite sure what you mean with your first question. I basically need Pi and Phi in the crazy four (?) versions I listed in the CONSTANTS definition I mentioned :) . Currently I don't see more special characters here. |
@S-Man42 I've implemented some additional default constants, and also the ability to specify custom constant symbols that the parser will recognise (which can be any string and don't have to match the identifier naming schema). In ExpressionParser parser = GrammarParser(ParserOptions(constants: {
'Π': math.pi,
'Φ': 1.6180339887,
})); See the CHANGELOG |
Works perfectly now regarding the constants! Thanks. Only the missing leading or trailing zero-issue is still not working. It would be a very nice feature, but is not a breaker on our side. |
Btw: Is it possible to remove fixed variables? I think e is an edge case I would not like to have in my parser. e() as function is already working and is used that way. However e has another meaning in our case. So can I switch it off? Edit: Explanation: Edit: I found a way! :)
|
@S-Man42 Thanks for testing! I hadn't considered that users may want to opt out of the built-in constants. The workaround you posted looks good to me, I will add it to the official documentation 😄 Edit: Added in 2c21520 - slightly more concise way: class MyGrammarParser extends GrammarParser {
MyGrammarParser([super.options]) {
constants.remove('e');
}
} |
Hi,
I have an input like
8E
After I put this into the parser for evaluation, the parser instantly converts it into
e({8.0})
Is there a way to suppress this behaviour? I expect to get an error (unparseable or something) instead.
The text was updated successfully, but these errors were encountered: