简体   繁体   English

如何在esprima解析器上添加新的语义?

[英]How can I add a new semantics on esprima parser?

I want to use esprima parser to parse mongo shell scripts. 我想使用esprima解析器来解析mongo shell脚本。 Basically mongo shell is using javascript syntax but with some additional commands. 基本上mongo shell使用的是JavaScript语法,但带有一些其他命令。 For example, use test is one statement on mongo shell to switch to the test database. 例如, use test是mongo shell上切换到test数据库的一条语句。 If I put this string to esprima.parseScript I will get an exception because this is not a valid javascript code. 如果我将此字符串放入esprima.parseScript ,则会收到异常,因为这不是有效的JavaScript代码。 I wonder what the easiest way for me to add some new semantics like use test on esprima parser. 我想知道对我来说,最简单的方法是在esprima解析器上添加一些新的语义,例如use test

Both Esprima and acorn has many bugs and doesn't support latest ecmascript. Esprima和橡子都有许多错误,并且不支持最新的ecmascript。 Have you looked at something like the Cherow parser? 您是否看过Cherow解析器之类的东西? https://github.com/cherow/cherow https://github.com/cherow/cherow

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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