Based on the previous optimized Java7 grammar by Terence Parr and Sam Harwell with the same BSD license. This grammar does not exactly corresponds to the formal Java specification unlike usual Java8 grammar, but passes tests such as AllInOne7.Java and AllInOne8.java. Performance, practical usage and clarity in priority.
This grammar parses the file ManyStringsConcat.java much more faster than original grammar without left recursion expressions.
- Java 7
- Java 8
- Terence Parr, 2013
- Sam Harwell, 2013
- Ivan Kochurkin (Positive Technologies), 2017
The grammar contains AllInOne7.java and AllInOne8.java files that almost fully covered Java syntax.
Grammar performance has been tested on the following projects:
- jdk8
- Spring Framework
- Elasticsearch
- RxJava
- JUnit4
- Guava
- Log4j
See Benchmarks page for details.
parserRule
: token1 (token2* OPERATOR token3?)
;
INT: 'int';
INTERFACE: 'interface';
fragment
HexDigit
: [0-9a-fA-F]
;
Please use token names instead of literal names if possible and justified. It's more convenient during parse tree bypass.
modifier
: classOrInterfaceModifier
| NATIVE
| SYNCHRONIZED
| TRANSIENT
| VOLATILE
;
instead of
modifier
: classOrInterfaceModifier
| 'native'
| 'synchronized'
| 'transient'
| 'volatile'
;