Skip to content

flex-development/esast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

esast

github release npm module type: esm license conventional commits typescript vitest yarn

ECMAScript Abstract Syntax Tree format.


esast is a specification for representing JavaScript as an abstract syntax tree.

It implements the unist spec.

Contents

Introduction

This document defines a format for representing ECMAScript as an abstract syntax tree. Development of esast started in March 2024. This specification is written in a TypeScript-like grammar.

Where this specification fits

esast extends unist, a format for syntax trees, to benefit from its ecosystem of utilities.

esast relates to ESTree in that the first is inspired by the latter; an esast is a unist-flavored estree.

esast relates to JavaScript in that it represents it, but esast is not limited to JavaScript and can be extended to support other JavaScript-based languages, like TypeScript.

ESTree

TODO: estree differences

Types

TypeScript users can integrate esast type definitions into their project by installing the appropriate packages:

yarn add @flex-development/esast
See Git - Protocols | Yarn  for details regarding installing from Git.

Nodes (abstract)

Node

interface Node extends unist.Node {}

Node (unist.Node) is a syntactic unit in esast syntax trees.

Literal

interface Literal extends Node {
  value: RegExp | bigint | boolean | number | string | null | undefined
}

Literal represents an abstract interface in esast containing a value.

Its value field is one of the following:

  • a regular expression (RegExp)
  • a bigint primitive
  • a boolean
  • a number
  • a string
  • null
  • undefined

Parent

interface Parent extends Node {
  children: Child[]
}

Parent represents an abstract interface in esast containing other nodes (said to be children).

The children field is a list representing the children of a node.

Nodes

TODO: nodes

This specification is a work in progess. Please refer to the source code for preliminary documentation.

Glossary

See the unist glossary.

List of utilities

See the unist list of utilities for more utilities.

Related

  • docast — docblock abstract syntax tree format
  • mdast — markdown abstract syntax tree format

Contribute

See CONTRIBUTING.md.

Ideas for new utilities and tools can be posted in esast/ideas.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.