Is there a BNF grammar available for JavaScript ES6?

I am working on a merge tool for JavaScript programs and I need to write a grammar for JavaScript (version> = ES6) in JavaCC format .

To do this, I want to use the openly available BNF grammar for ES6 and then write a JavaCC grammar from it.

I only managed to find those (from this Karu question ):

However, these are very old BPF (and the question of Karu is also very old, 11 years ago). These grammars only work - and in a limited way - for the & lt; ES5.

Are you aware of the newer public grammar (BNF, JavaCC file, etc.)?

There are parsers available for ES6 like Esprima , but since I have to use the JavaCC environment, I need a grammar to work.

+2


source to share


2 answers


The fully approved latest ECMAScript version (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 (original repo) and https://tc39.github.io/ecma262/ (displayed).



All this is openly accessible and contains grammar for the language. The grammar notation is mostly BNF with some extensions.

+1


source


ANTLR



Take a look at the JavaScript grammar from the ANTLR grammar repository .

+2


source







All Articles