We've released Exevalator (a compact expression-evaluation library) Ver. 2.2.2.
This post walks you through what's new in this update.
First, a quick refresher — what exactly is Exevalator?
Exevalator is a library for use cases where you need to evaluate a mathematical expression given as a string and obtain its result in your app.
For example, given strings like:
it returns the results:
In short, it behaves like a scientific calculator you can embed in your application.
In fact, the recently released online version of the RINPn scientific calculator uses Exevalator for computation: Inside RINPn Online: Architecture Overview
At RINEARN we develop several language processing systems, and Exevalator keeps its implementation very compact by focusing solely on expression evaluation.
Concretely, the entire logic fits in a single file, so you can just drop it into your project's source folder and use it — a true single-file library.
Because it's compact, it's easy to port. As of now it supports six languages: Java, Rust, C++, C#, VB.NET, and TypeScript. Python support is planned in the near future.
That's the gist of Exevalator. For details, please see the official site:
Exevalator is open source, and the repository is on GitHub. If you're comfortable with GitHub, jumping straight there may be the fastest route:
Here's what's new in this update.
As a baseline, if you use Exevalator as-is, error messages are shown in English. For example:
There are cases where you’d prefer Japanese, like:
So how do you customize the error messages?
That's the basic approach. It's straightforward, but since Exevalator is a small single-file library, we believe this approach is preferable to adding heavy mechanisms.
That said, many people will want "Japanese messages" specifically, and having everyone translate them individually would be wasteful.
So from this release, we've bundled a Japanese-translated error-message file: `ERROR_MESSAGE_JAPANESE.*`: https://github.com/RINEARN/exevalator/blob/main/java/ERROR_MESSAGE_JAPANESE.java
Just copy and paste its contents to overwrite the error-message section in the Exevalator source, and you're done — messages will appear in Japanese.
In addition to the above, this release includes a few fixes and tweaks.
Previously, expressions with multiple consecutive unary minus operators were not handled correctly, e.g.:
While such forms are uncommon (hence missing from our tests), they should be interpreted as:
However, the parser's analysis went wrong, and incorrect values such as 5.6 were returned (the exact wrong value depended on the expression).
This has been fixed in the current version.
» Commit
We sincerely apologize for any inconvenience caused by this bug.
We also fixed a bug where an expression containing parentheses around a single value would cause an error, for example:
» Commit
This bug affected the TypeScript version only; other language implementations were not affected.
Alongside the first fix, we made a small algorithmic adjustment to the parser:
» Commit
Concretely, the comma used as a function-argument separator (,) is now treated as an operator rather than as a special grammar case.
This change requires no action from library users and should have no visible effect in normal use. If you extend or modify the parser itself, please take note.
-
That's all for this update.
We'll continue to share Exevalator news here as things progress!