سؤال

Are there any tools available for producing a parse tree of NodeJS code? The closest I can find is the closure compiler but I don't think that will give me a parseable tree for analysis.

هل كانت مفيدة؟

المحلول

Node.js is just JavaScript (aka ECMAScript). I recommend Esprima (http://esprima.org/), which supports the de-facto standard AST established by Mozilla.

نصائح أخرى

Esprima generates very nice ASTs, but if you need the parse tree you must look elsewhere. Esprima only returns ASTs and the sequence of tokens for some text. If you don't want to model the language yourself, you could use another tool like ANTLR (see: https://stackoverflow.com/a/5982455/206543).

For the difference between ASTs and parse trees, look here: https://stackoverflow.com/a/9864571/206543

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top