expr-eval
expr-eval copied to clipboard
Feat: percent support
Like 50 + 10%.
Strange cases:
50 + 10% - 5 — it can't be treated as 10 % -5, right?)
50 + 10% + 5 — if you going to get mod — you avoid using plus sign, right?.
As far as I see other operators after a percent sign could be treated as a syntax error.
p.s. Probably it could be nice to see some units support like 5cm, but it's another story.
I'm considering this for a future release, but I'll need to work out the details of how it would work (including the parsing issues you brought up). I might end up replacing the current usage with a mod operator to avoid ambiguities and use % exclusively for percentages. I can definitely see how it would be nice for some use cases.
I think it's fully compatible with % binary operator:
- after binary
%must be an expression - after unary
%can be an operator or nothing
+1