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:
- interface Node {
- type: string;
- }
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:
- interface Node {
- type: string;
- range?: [number, number];
- loc?: SourceLocation;
- }
with the source location defined as:
- interface Position {
- line: number;
- column: number;
- }
- interface SourceLocation {
- start: Position;
- end: Position;
- source?: string | null;
- }