I am working on a merge tool for JavaScript programs, and I need to write a grammar for JavaScript (version >= ES6) in JavaCC format.
For that, I want to use an openly available BNF grammar for ES6, then I would write the grammar in JavaCC format from it.
I was able to find only those (from this Stack Overflow question):
However, these are very old BNFs (and the question on StackOverflow is also very old, from 11 years ago). These grammars work only - and in a limited manner - for versions < ES6.
Do you know about a newer publicly available grammar (BNF, JavaCC file, etc)?
There are parsers available for ES6, such as Esprima, but, since I have to use JavaCC environment, I need the grammar to work on.
The fully-approved latest version of ECMAScript (ES2017 = ES8) is at https://www.ecma-international.org/publications/standards/Ecma-262.htm
The latest draft of the next version (ES2018) is at https://github.com/tc39/ecma262 (source repo) and https://tc39.github.io/ecma262/ (rendered).
All of these are openly available and contain a grammar for the language. The grammar notation is mostly BNF with some extensions.
Take a look at the JavaScript grammar from the ANTLR grammars repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With