language-javascript icon indicating copy to clipboard operation
language-javascript copied to clipboard

Mozilla Parser API

Open mvcisback opened this issue 10 years ago • 3 comments

Hey, it'd be really cool if this tool could emit json compatable with the Mozilla Parser API. Alot of tools conform to it, so it'd make hooking into them alot easier.

I believe it should be a (lossy) transformation on the AST implemented.

mvcisback avatar Jun 22 '14 05:06 mvcisback

It looks interesting. Pull requests welcomed :)

alanz avatar Jun 22 '14 07:06 alanz

I whipped up a prototype type specification yesterday: https://github.com/mvcisback/parser_api/blob/master/MozillaApi.hs

It's pretty heavily based on https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API with the omission of E4X stuff. I think there should be a pretty 1-1 transformation of that to the JSON SpiderMonkey and acorn (and a few other parsers) emit.

I imagine the conversion from to the more concrete syntax to the mozilla parser api might require abit of time for me to figure out, although it looks like showStripped does alot of what I will need.

mvcisback avatar Jun 22 '14 20:06 mvcisback

See also https://github.com/jswebtools/mozilla-js-parser-api, more tests, bug reports, pull requests are welcome.

achudnov avatar Jul 29 '15 18:07 achudnov