• Stars
    star
    6,094
  • Rank 6,602 (Top 0.2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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:

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.

More Repositories

1

JSNetworkX

Build, process and analyze graphs in JavaScript (port of NetworkX)
JavaScript
759
star
2

jQuery-Function-Toggle-Plugin

A jQuery plugin that binds multiple event handlers which are executed on each consecutive event
JavaScript
43
star
3

floatnotes

A Firefox extension that let you create post-it like notes on any website.
JavaScript
26
star
4

docblock-parser

A standalone line based doc block parser.
JavaScript
18
star
5

Game-of-Life

A Game of Life implementation in JavaScript
JavaScript
18
star
6

jsbasics

An interactive introduction to basic and important concepts of JavaScript
JavaScript
14
star
7

PHP-functions

A collection of useful PHP functions
PHP
12
star
8

flow-typestrip

A recast based transform to remove Flow type annotations.
JavaScript
8
star
9

jsdeepdive

A jsbasics fork, focusing more on advanced topics
JavaScript
7
star
10

deep-equal-ident

A function to test for identity-based deep equality
JavaScript
6
star
11

WebIntelligence

This is a project for a university course
Python
6
star
12

JSMashup

Early prototype of a modular JavaScript library for handling the internal logic of mashup compositions.
JavaScript
4
star
13

Web2

Java
3
star
14

devenv

My devenv and tools setup
Shell
3
star
15

ecmascript-inspector

2
star
16

TurnJS

A libary for turn-based games.
JavaScript
2
star
17

chai-members-deep

This extends chai.js with deep equality member checks, optionally also tracking the idenitfy of nested objects.
JavaScript
2
star
18

jQuery-text-highlight

A collection of various jQuery plugins or ideas. Feel free to use and expand them.
2
star
19

promise

A tiny promise library.
JavaScript
1
star
20

lda_model_viewer

An experimantal model viewer for LDA model files generated by plda.
JavaScript
1
star