Appendix A. Syntax Tree Format

Esprima syntax tree format is derived from the original version of Mozilla Parser API, which is then formalized and expanded as the ESTree specification.

Note: In the following sections, interfaces are described using the syntax of TypeScript interface.

Each node is represented as a regular JavaScript object that implements the interface:

  1. interface Node {
  2. type: string;
  3. }

The type property is a string that contains the variant type of the node. Each subtype of Node is explained in the subsequent sections.

When the node is annotated with its location, the interface becomes:

  1. interface Node {
  2. type: string;
  3. range?: [number, number];
  4. loc?: SourceLocation;
  5. }

with the source location defined as:

  1. interface Position {
  2. line: number;
  3. column: number;
  4. }
  5.  
  6. interface SourceLocation {
  7. start: Position;
  8. end: Position;
  9. source?: string | null;
  10. }