astexplorer

A web tool to explore the ASTs generated by various parsers.

Github星跟踪图

AST explorer

Join the chat at https://gitter.im/astexplorer/Lobby
Build Status

Paste or drop code into the editor and inspect the generated AST on https://astexplorer.net/

The AST explorer provides following code parsers:

Experimental / custom syntax

Depending on the parser settings, it not only supports ES5/CSS3 but also

Transforms

Since future syntax is supported, the AST explorer is a useful tool for
developers who want to create AST transforms. In fact, following transformers
are included so you can prototype your own plugins:

More Features

  • Save and fork code snippets. Copy the URL to share them.
  • Copying an AST or dropping a file containing an AST into the window will
    parse the AST and update the code using escodegen.
  • Otherwise, the content of text editor will be replaced with the content of the
    file (i.e. you can drag and drop JS files).
  • Choose between multiple parsers and configure them.
  • shift+click on a node expands the full subtree.
  • Hovering over a node highlights the corresponding text in the source code
  • Editing the source or moving the cursor around will automatically highlight
    the corresponding AST node (or its ancestors of it isn't expanded)
  • You can use $node in the console to refer to the last opened/toggled AST
    node.

Contributions

I'm happy about any feedback, feature request or PR to make this tool as useful
as possible!


How to add a new parser

  1. Go to website/.
  2. Install the new parser as dependency: yarn add theParser (or npm install -S theParser)
  3. Copy one of the existing examples in src/parsers/{language}.
  4. Adjust the code as necessary:
  • Update metadata.
  • Load the right parser (loadParser).
  • Call the right parsing method with the right/necessary options in parse.
  • Implement the nodeToRange method (this is for highlighting).
  • Implement the getNodeName method (this is for quick look through the tree).
  • Implement opensByDefault method for auto-expansion of specific properties.
  • Define _ignoredProperties set or implement forEachProperty generator method for filtering.
  • Provide a renderSettings method if applicable.

How to add a new transformer

  1. Go to website/.
  2. Install the new transformer as dependency.
  3. Copy one of the existing examples in src/parsers/{language}/transformers.
  4. Adjust the code as necessary:
  • Update metadata and defaultParserID.
  • Load the right transformer (loadTransformer).
  • Call the transformation method in transform.
  • Change sample transformation code in codeExample.txt.

Build your own version for development

  1. Clone the repository.
  2. Go to website/.
  3. Install all dependencies with yarn install (you can run npm install as
    well).

Run yarn run build for the final minimized version.
Run yarn run watch for incremental builds.

Run yarn start to start a simple static webserver.

主要指标

概览
名称与所有者fkling/astexplorer
主编程语言JavaScript
编程语言CSS (语言数: 5)
平台
许可证MIT License
所有者活动
创建于2014-06-30 05:25:09
推送于2024-04-26 13:48:46
最后一次提交2024-02-03 21:53:25
发布数17
最新版本名称v2.1.0 (发布于 )
第一版名称v1.0.0 (发布于 2015-11-20 22:38:54)
用户参与
星数6.4k
关注者数57
派生数755
提交数1k
已启用问题?
问题数294
打开的问题数111
拉请求数328
打开的拉请求数40
关闭的拉请求数69
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?