What is JavaScript AST, how to play with it?

后端 未结 4 477
陌清茗
陌清茗 2020-12-02 07:06

Abstract Syntax Tree.. I always heard that compile to SpiderMonkey AST on Github.
So, is that a actual standard of JS syntax tree? And there\'s V8, is V8 using the same

4条回答
  •  一生所求
    2020-12-02 07:40

    If you would like to try out the acron parser from professor Marijnh https://github.com/marijnh try out this link: https://astexplorer.net/

    This is a tiny, fast JavaScript parser, written completely in JavaScript.

    The above-mentioned JavaScript AST visualizer uses Esprima engine and has been also written in JavaScrpt.

    JavaScript dominates in parsing AST because JavaScript engines are super optimized today. https://en.wikipedia.org/wiki/JavaScript_engine

    SpiderMonkey AST standard of JS syntax tree? Is V8 using the same kind of AST?

    Both of these web browser engines do have AST processing inside written in C++. This is why JavaScrpt code will run fast in most cases except for eval.

提交回复
热议问题