Have you struggled with precedence and associativity rules when parsing an expression using
So the last few months, I have slowly worked on a solution that hopefully would end the pain for most users.
I’m now quite pleased with the API, implementation and documentation, I don’t know what to remove anymore from it, so after a small round of feedback and a few versions iterations, I’m ready to share it:
This package was designed with the following goals:
- Seamless integration in the
- As user-friendly as possible
- Minimalist but flexible API that should meet most users needs
- Let most of the parsing control to users, including error messages
- Low footprint (the package is currently 135 LOC without comments, whatever that means)
- Tail-Call Elimination for left-associative operations
- No backtracking
- Reasonable documentation and test suite
If you are interested, read the
README and play with this Ellie example that allows to dynamically change the precedences of a mathematical expression (use
RELOAD to reset):
I intend to maintain this package as long as needed, as I use it myself, so feedback and bugs reports are very welcome, including about the documentation and API.
- Thank you @Punie for motivating me to publish it, and @Janiczek for the naming brainstorming session.
- Thank you to the authors and contributors of elm-format, elm-verify-examples, elm-xref, elm-analyse, elm-test, ellie, elm-live, idiomatic-elm-package-guide, design-guidelines, and others I forgot, these tools and resources have been tremendously useful. Also Travis CI configuration is now a breeze, this is wonderful.