GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - fkling/astexplorer: A web tool to explore the ASTs generated by various parsers.

BranchesTags
Open more actions menu

Latest commit

 

History

981 Commits
981 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/ISSUE_TEMPLATE
.github/ISSUE_TEMPLATE
 
 
assets
assets
 
 
scripts
scripts
 
 
server
server
 
 
website
website
 
 
.editorconfig
.editorconfig
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.gitlab-ci.yml
.gitlab-ci.yml
 
 
.gitpod.yml
.gitpod.yml
 
 
.tool-versions
.tool-versions
 
 
.travis.yml
.travis.yml
 
 
CNAME
CNAME
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 

Repository files navigation

AST explorer

Gitpod ready-to-code 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:

  • CSS:
    • cssom
    • csstree
    • postcss + postcss-safe-parser & postcss-scss
    • rework
  • GraphQL
  • Graphviz:
    • redot
  • Handlebars:
    • glimmer
    • handlebars
    • ember-template-recast
  • HTML:
    • htmlparser2
    • parse5
    • @angular/compiler
    • @angular-eslint/template-parser
    • svelte
    • posthtml
    • hyntax
  • Vue:
    • vue-template-compiler
    • @vue/compiler-core
    • vue-eslint-parser
  • ICU
  • Java
    • java-parser
  • JavaScript:
    • acorn + acorn-jsx
    • babel-eslint
    • babylon
    • espree
    • esformatter
    • esprima
    • flow-parser
    • hermes-parser
    • meriyah
    • recast
    • seafox
    • shift
    • swc
    • traceur
    • typescript
    • typescript-eslint-parser
    • uglify-js
  • JSON:
    • JSON
    • Momoa
  • Lua:
    • luaparse
  • Markdown:
    • remark
  • MDX:
    • mdxhast
  • Monkey
    • monkey
  • PHP
    • php-parser
  • Pug
  • Regular Expressions:
    • regexp-tree
    • regexpp
    • regjsparser
  • Protocol Buffers:
    • pbkit
  • Scala
    • Scalameta
  • Solidity:
    • solidity-parser-antlr
  • SQL:
    • sqlite-parser
  • Svelte:
    • svelte
  • WebIDL
  • YAML:
    • yaml
    • yaml-ast-parser

Experimental / custom syntax

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

  • ES6: arrow functions, destructuring, classes, ...
  • ES7 proposals: async/await, object rest / spread, ...
  • JSX, known through React.
  • Typed JavaScript (Flow and TypeScript)
  • SASS

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:

  • JavaScript
    • babel (v5, v6)
    • ESLint (v1, v2, v3)
    • jscodeshift
    • tslint
  • HTML
    • posthtml
  • CSS
    • postcss
  • MDX
    • mdx
  • Regular Expressions
    • regexp-tree
  • Handlebars
    • glimmer

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
  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

IMPORTANT: For various reasons the project still requires Node.js version 16 (see .tools-versions). If you use a tool like asdf switching versions will happen automatically.

  1. Clone the repository.
  2. Go to website/.
  3. Install all dependencies with yarn install

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.

About

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

astexplorer.net/

Topics

astast-explorerbabeljavascriptjscodeshiftparserpostcss

Resources

Readme
MIT license
Activity

Stars

6.5k stars

Watchers

55 watching

Forks

764 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.