Actually, this is grammar for Java Compiler Compiler (JavaCC,
https://javacc.dev.java.net/)
And, of course this is not pure java
I need parser for math expressions with possibility to override operators (third-party tools which I founded are either do not have this feature or heavy and costs a lot).
And it's stupid idea to write my own parser while there are such tools already exists: JavaCC, ANTLR, yacc, SableCC, etc.
So, I decided to use JavaCC, wrote simple grammar, compiled it (received a bunch of pure Java classes which represents Lexer and Parser).
By passing some
string expression to Parser (i.e. like "1+2+3/(5+3)") to it - I am receiving results of this expression.