GithubHelp home page GithubHelp logo

cpojer / esprima_ast_explorer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fkling/astexplorer

0.0 3.0 1.0 6.99 MB

An web tool to explore the AST generated by esprima harmony.

Home Page: http://felix-kling.de/esprima_ast_explorer/

CSS 21.24% HTML 1.72% JavaScript 76.80% Shell 0.24%

esprima_ast_explorer's Introduction

A JavaScript AST explorer

Paste JavaScript code into the editor and inspect the generated AST.

The JavaScript AST explorer provides

to parse the code. Depending on the parser settings, it not only supports ES5 but also

Since future syntax is supported, the JavaScript AST explorer is a useful tool for developers who want to create AST transforms, e.g. with recast. In fact, jscodeshift is included so you can prototype codemodding scripts.

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 texteditor 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.
  • Toggle Transform mode with jscodeshift.
  • shift+click on a node expands the full subtree.
  • Hovering over a node highlights the corresponding text in the source code: source highlight
  • Editing the source or moving the cursor around will automatically highlight the corresponding AST node (or its ancestors of it isn't expanded): source highlight

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. Install the new parser as dependency: npm install -S theParser
  2. Copy one of the existing examples in src/parsers/.
  3. Adjust the code as necessary:
  • Load the right parser.
  • Call the right parsing method with the right/necessary options.
  • Implement the nodeToRange method (this is for highlighting).
  • Provide a renderSettings method if applicable.
  1. Add a new import to src/parser/index.js.
  2. Add the module to partition.json (either as new bundle or to an existing one of there are cross-dependencies).

Build your own version

Install all dependencies with npm install.

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

Run npm start to start a simple static webserver.

esprima_ast_explorer's People

Contributors

cpojer avatar fkling avatar hzoo avatar juanpicado avatar pieterv avatar voideanvalue avatar

Watchers

 avatar  avatar  avatar

Forkers

kentaromiura

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.