Node
The basic building block of the Abstract Syntax Tree (AST). In general node represent non-terminals in the language grammar; some terminals are kept in the tree such as identifiers and literals.
Two key things make up an AST node documentation. Its SyntaxKind
which identifies it within the AST and its interface
, the API the node provides when instantiated for the AST.
Here are a few key interface Node
members:
TextRange
members that identify the node'sstart
andend
in the source file.parent?: Node
the parent of the node in the AST.
There are other additional members for node flags and modifiers etc. that you can lookup by searching interface Node
in the source code but the ones we mentioned are vital for node traversal.
SourceFile
SyntaxKind.SourceFile
interface SourceFile
.
Each SourceFile
is a top-level AST node that is contained in the Program
.