Comments (10)
I plan a release after some more issues are fixed, will be soon.
from evalex.
After debugging some nonsense & evaluable strings, I think the culprit is in this line
When I try the normal expressions, the operandStack
size is mostly 1
so it'll take the whole tokenized node.
However, when I try the nonsense strings, the operandStack
size is higher than 1
(Test 2 + 2 2 + 3
would be 3
) and the line would take the last node in the stack.
I think we should include another exception check when operandStack
is higher than 1
after the Shunting Yard conversion.
EDIT: Is there any legit case where the operandStack
size is higher than 1
? Because I could be wrong since I only tested with a little part of the Unit Tests.
from evalex.
When looking at it quickly back then, I also noticed this. There may be some use case if you use functions with multiple parameters. You could try how it behaves for an
if
call for example.
It's verified that the size is also 1
(IF(5 + 2 > 3, 5 + 2, 2 + 3) + FLOOR(11.2)
).
I'll make a PR and wait for the owner to reply further more.
from evalex.
I believe that is implicit multiplication at work.
Test 2 + 2 2 + 3
0 2 + 2 2 + 3
0*2 + 2*2 + 3
0 + 4 + 3 = 7
Basically, but seems like the first one is dropped somewhen before the actual evaluation because the variable is not set.
from evalex.
I don't think that's the case. An unset variable should error out, but it doesn't because it's already dropped before the abstract syntax tree is evaluated.
Another example: 2 3 + 4
evaluates to 7, which completely ignores the 2. If it was implicit multiplication, it should result in 9.
from evalex.
That's true, then I'm out of ideas.
from evalex.
Test World
would become {"type":"VARIABLE_OR_CONSTANT","value":"World"}
Test World Hello
would become {"type":"VARIABLE_OR_CONSTANT","value":"Hello"}
Test World 1
would become {"type":"NUMBER_LITERAL","value":"1"}
So, same issue I guess.
from evalex.
When looking at it quickly back then, I also noticed this. There may be some use case if you use functions with multiple parameters. You could try how it behaves for an if
call for example.
from evalex.
Thanks for the fix and merge! Will there be a patch release with this fix applied in the near future?
from evalex.
Alright, no rush, thanks for the info though!
from evalex.
Related Issues (20)
- How to restrict list of operators used in formula evaluation? HOT 1
- Custom ! post fix operator is not called HOT 1
- decimalPlacesRounding has confusing behavior HOT 5
- NoSuchElementException not being caught HOT 2
- Allow to only round the final result
- OutOfMemoryError: for wrong expression with 2 dots HOT 1
- Support arrays as function parameters HOT 7
- Equality depends on input type in 3.1.0
- problem with placeholder HOT 1
- Add module-info (or at least Automatic-Module-Name) HOT 2
- SQRT function doesn't work HOT 3
- With introduction of null, it's better to allow short circuiting (lazy evaluation) for those boolean operators HOT 4
- Equals/NotEquals operator is now sometimes showing inconsistent behavior HOT 1
- Broken boolean expression evaluation in version 3.1.0
- Allow Java arrays as input parameters
- Restore compatibility with Java 8 HOT 2
- Determine evaluation result type without evaluating HOT 2
- Java exception generated when trying to calculate expressions (it worked before with the original EvalEX library in the previous GitHub) HOT 2
- Can arrayJson filtering be supported? HOT 3
- Add a configurable locale to the configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from evalex.