recast - JavaScript syntax tree transformer, nondestructive pretty-printer, and automatic source map generator

  •        46

In less poetic terms, Recast exposes two essential interfaces, one for parsing JavaScript code (require("recast").parse) and the other for reprinting modified syntax trees (require("recast").print). See ast-types (especially the def/core.js) module for a thorough overview of the ast api.

http://github.com/benjamn/recast

Dependencies:

ast-types : 0.10.2
esprima : ~4.0.0
private : ~0.1.5
source-map : ~0.6.1

Tags
Implementation
License
Platform

   




Related Projects

ast-types - Esprima-compatible implementation of the Mozilla JS Parser API

  •    Javascript

This module provides an efficient, modular, Esprima-compatible implementation of the abstract syntax tree type hierarchy pioneered by the Mozilla Parser API. Because it understands the AST type system so thoroughly, this library is able to provide excellent node iteration and traversal mechanisms.

grunt-babel - Grunt plugin for Babel

  •    Javascript

Issues with the output should be reported on the Babel issue tracker.See the Babel options, except for filename which is handled for you.

gulp-babel - Gulp plugin for Babel

  •    Javascript

Issues with the output should be reported on the Babel issue tracker.See the Babel options, except for sourceMap and filename which is handled for you.

treehugger - JavaScript AST (Abstract Syntax Tree) transformation tools

  •    Javascript

JavaScript AST (Abstract Syntax Tree) transformation tools


redbaron - Bottom-up approach to refactoring in python

  •    Python

RedBaron is a python library and tool powerful enough to be used into IPython solely that intent to make the process of writing code that modify source code as easy and as simple as possible. That include writing custom refactoring, generic refactoring, tools, IDE or directly modifying you source code into IPython with a higher and more powerful abstraction than the advanced texts modification tools that you find in advanced text editors and IDE. RedBaron guaranteed you that it will only modify your code where you ask him to. To achieve this, it is based on Baron a lossless AST for Python that guarantees the operation ast_to_code(code_to_ast(source_code)) == source_code. (Baron's AST is called an FST, a Full Syntax Tree).

cmark - CommonMark parsing and rendering library and program in C

  •    C

It provides a shared library (libcmark) with functions for parsing CommonMark documents to an abstract syntax tree (AST), manipulating the AST, and rendering the document to HTML, groff man, LaTeX, CommonMark, or an XML representation of the AST. It also provides a command-line program (cmark) for parsing and rendering CommonMark documents. Portable. The library and program are written in standard C99 and have no external dependencies. They have been tested with MSVC, gcc, tcc, and clang.

jstransform - A simple utility for pluggable JS syntax transforms using the esprima parser.

  •    Javascript

A simple utility for pluggable JS syntax transforms using the esprima parser. Note: If you're looking for a library for writing new greenfield JS transformations, consider looking at Babel or Recast instead of jstransform. We are still supporting jstransform (and intend to for a little while), but longer term we would like to direct efforts toward other open source projects that do a far better job of supporting a multi-pass JS transformation pipeline. This is important when attempting to apply many transformations to a source file. jstransform does a single pass resulting in performance benefits, but the tradeoff is that many transformations are much harder to write.

jsfmt - For formatting, searching, and rewriting JavaScript.

  •    Javascript

For formatting, searching, and rewriting JavaScript. Analogous to gofmt. If no path is given it will read from stdin. A directory path will recurse over all *.js files in the directory.

c2rust - C to Rust translation, refactoring, and cross-checking

  •    Rust

The ast-exporter extracts from a C file the abstract syntax tree and type information produced by Clang and serializes it into CBOR files. The ast-importer consumes these CBOR files and generates Rust source code preserving the semantics (as understood under C99) of the initial C program. The translated Rust files will not depend directly on each other like normal Rust modules. They will export and import functions through the C API. These modules can be compiled together into a single static Rust library.

esprima - ECMAScript parsing infrastructure for multipurpose analysis

  •    TypeScript

Esprima (esprima.org, BSD license) is a high performance, standard-compliant ECMAScript parser written in ECMAScript (also popularly known as JavaScript). Esprima is created and maintained by Ariya Hidayat, with the help of many contributors. Esprima can be used to perform lexical analysis (tokenization) or syntactic analysis (parsing) of a JavaScript program.

react-docgen - A CLI and toolbox to extract information from React component files for documentation generation purposes

  •    Javascript

react-docgen is a CLI and toolbox to help extracting information from React components, and generate documentation from it.It uses recast and babylon to parse the source into an AST and provides methods to process this AST to extract the desired information. The output / return value is a JSON blob / JavaScript object.

Prettier - An opinionated code formatter.

  •    Javascript

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary. Prettier can be run in your editor on-save, in a pre-commit hook, or in CI environments to ensure your codebase has a consistent style without devs ever having to post a nit-picky comment on a code review ever again!

CustomTemplating - Template Text Transformations with custom T4 host

  •    CSharp

CustomTemplating allows the usage of the Text Template Transformation Toolkit (T4) from custom applications, without VS IDE as Host. It simplifies the start of the text transformation process and allow to pass arguments from the application to the template transformation process.

Java Pretty Printer Library

  •    Java

A Java package for pretty-printing a text by deciding where to introduce line-breaks and indentation. A Java implementation of Derek Oppen\'s pretty printing algorithm. It is _not_ a pretty printer for Java code, though it could be used to write one.

swagger-codegen - swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition

  •    HTML

📔 The eBook A Beginner's Guide to Code Generation for REST APIs is a good starting point for beginners. Check out OpenAPI-Spec for additional information about the OpenAPI project.

react-syntax-highlighter - syntax highlighting component for react with prismjs or highlightjs ast using inline styles

  •    Javascript

Check out a small demo here and see the component in action highlighting the generated test code here. There are other syntax highlighters for React out there so why use this one? The biggest reason is that all the others rely on triggering calls in componentDidMount and componentDidUpdate to highlight the code block and then insert it in the render function using dangerouslySetInnerHTML or just manually altering the DOM with native javascript. This utilizes a syntax tree to dynamically build the virtual dom which allows for updating only the changing DOM instead of completely overwriting it on any change, and because of this it is also using more idiomatic React and allows the use of pure function components brought into React as of 0.14.

php-parser - PHP parser written in Go

  •    Go

This project uses goyacc and golex libraries to parse PHP sources into AST. It can be used to write static analysis, refactoring, metrics, code style formatting tools. Dump AST to stdout.

espree - An Esprima-compatible JavaScript parser

  •    Javascript

Espree started out as a fork of Esprima v1.2.2, the last stable published released of Esprima before work on ECMAScript 6 began. Espree is now built on top of Acorn, which has a modular architecture that allows extension of core functionality. The goal of Espree is to produce output that is similar to Esprima with a similar API so that it can be used in place of Esprima. The primary goal is to produce the exact same AST structure and tokens as Esprima, and that takes precedence over anything else. (The AST structure being the ESTree API with JSX extensions.) Separate from that, Espree may deviate from what Esprima outputs in terms of where and how comments are attached, as well as what additional information is available on AST nodes. That is to say, Espree may add more things to the AST nodes than Esprima does but the overall AST structure produced will be the same.

pretty - Pretty printing for Go values

  •    Go

Pretty printing for Go values