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 nodetype
: The name of the grammr production that produced the nodechildren
: An array of{ type, value }
objects, wheretype
is one ofLiteral
,Trivia
,Escape
,Gap
orReference
. Children never contain hard linkages to other nodes, but they can contain refer to them using the opqueReference
type.properties
: An object of the form{ [pathName]: node }
or{ [pathName]: [...nodes] }
.attributes
: An object of the form{ [attrName]: 'attrValue' }
or{ [attrName]: true }
.