简体   繁体   中英

How can I add a new semantics on esprima parser?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM