Parser for ES6?

joe joeedh at gmail.com
Thu May 7 16:54:03 UTC 2015


There's my crappy transpiler:

https://github.com/joeedh/fairmotion/tree/master/tools/extjs_cc

Which uses a parser generator (and yes, the standard is quite helpful in
pointing out ways to make JS work in a bottom-up grammar).   The grammar is
inline with the code, so I've extracted it and attached it to this email.
Note that I've extended the grammar a bit, mostly to implement a type
annotation system but there are a few other non-standard things as well (I
still need to replace my python-style multiline strings with template
strings, for example).  The grammar is also a bit messy.

I believe the only thing I'm missing is template strings and some of the
new numeric literal stuff (e.g. binary literals).  I just recently added a
bunch of stuff in preparation to move my codebase to a different transpiler
(one I don't have to maintain myself).  Oh, and I think I'm missing yield
assignments in generators (e.g. var x = yield y), too.  Also, I'm not sure
if arrow functions work in all cases, I have an ambiguity in my grammar
there (which I don't feel like debugging because I'm switching to babel :)
).

The regular expression stuff is kindof interesting; figuring out how to
parse RE literals wasn't easy (it's not strictly possible to parse them
with a RE tokenizer, but I managed to hackishly make it work).

Joe


On Thu, May 7, 2015 at 8:37 AM, Park, Daejun <dpark69 at illinois.edu> wrote:

> Hi,
>
> Is there any parser for ES6? It seems that no implementation completely
> supports ES6 yet (http://kangax.github.io/compat-table/es6/), and I'm
> just curious to see if there is at least a parser supporting all the
> features of ES6. For example, the grammar given in the spec seems to be fit
> to a parser generator, and I wonder if the grammar has been mechanized in
> such a parser generator or is just a written spec.
>
> Best,
> Daejun
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150507/c7f84ee2/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grammar
Type: application/octet-stream
Size: 15091 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150507/c7f84ee2/attachment-0001.obj>


More information about the es-discuss mailing list