How can I add a new semantics on esprima parser?

121 views Asked by At

I want to use esprima parser to parse mongo shell scripts. Basically mongo shell is using javascript syntax but with some additional commands. For example, use test is one statement on mongo shell to switch to the test database. If I put this string to esprima.parseScript I will get an exception because this is not a valid javascript code. I wonder what the easiest way for me to add some new semantics like use test on esprima parser.

1

There are 1 answers

0
Confused On

Both Esprima and acorn has many bugs and doesn't support latest ecmascript. Have you looked at something like the Cherow parser? https://github.com/cherow/cherow