Skip to content

Instantly share code, notes, and snippets.

@conartist6
Last active November 29, 2023 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conartist6/cce4b74b057b910c2e1b762e9c8d9b4d to your computer and use it in GitHub Desktop.
Save conartist6/cce4b74b057b910c2e1b762e9c8d9b4d to your computer and use it in GitHub Desktop.
agAST

What is agAST?

agAST is a generalized AST format for javascript. It is the format created for and used by the BABLR VM. It is meant to specify basic aspects of how tools store programs, so that common tools can be used to work on programs written in any programming language.

agAST is meant to be the successor to the existing ESTree specification. Unlike ESTree, agAST has no language-specific opinions.

agAST trees are made up of nodes of the following shape:

let node = {
  language,
  type,
  children,
  properties,
  attributes
}

Here are what each are for:

  • language: A resolveable symbolic reference to the grammar that parsed the node
  • type: The name of the grammr production that produced the node
  • children: An array of { type, value } objects, where type is one of Literal, Trivia, Escape, Gap or Reference. Children never contain hard linkages to other nodes, but they can contain refer to them using the opque Reference type.
  • properties: An object of the form { [pathName]: node } or { [pathName]: [...nodes] }.
  • attributes: An object of the form { [attrName]: 'attrValue' } or { [attrName]: true }.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment