You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/compiler/ast.md
+7-2
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,13 @@
1
1
## Node
2
2
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.
3
3
4
-
## Note on AST description
5
-
Two key things make up an AST node definition. Its `SyntaxKind` which identifies it within the AST and its `interface`, the API the node provides when instantiated for the AST.
4
+
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.
5
+
6
+
Here are a few key `interface Node` members:
7
+
*`TextRange` members that identify the node's `start` and `end` in the source file.
8
+
*`parent?: Node` the parent of the node in the AST.
9
+
10
+
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.
Copy file name to clipboardExpand all lines: docs/compiler/overview.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,14 @@ It is split into the follow key parts:
7
7
* Binder (`bindder.ts`)
8
8
* Checker (`checker.ts`)
9
9
* Emitter (`emitter.ts`)
10
+
* Program (`program.ts`)
10
11
11
12
Each of these get their own unique files in the source. These parts will be explained later on in this chapter.
12
13
13
14
There are a few additional files in the TypeScript compiler that provide utilities to many of these key portions:
14
15
15
16
## File: Utilities
16
-
core.ts : core utilities used by the TypeScript compiler
17
+
`core.ts` : core utilities used by the TypeScript compiler
17
18
18
19
## File: Key Data Structures
19
20
`types.ts` contains key data structures and interfaces uses throughout the compiler. Here is a sampling of a few key ones:
@@ -22,10 +23,9 @@ The AST node type is identified by the `SyntaxKind` enum.
22
23
*`TypeChecker`
23
24
This is the interface provided by the TypeChecker.
24
25
*`CompilerHost`
25
-
This is used by the `Program` to interact with the `System`
26
+
This is used by the `Program` to interact with the `System`.
27
+
*`Node`
28
+
A AST node.
26
29
27
30
## File: System
28
31
All interaction of the TypeScript compiler with the operating system goes through a `System` interface. Both the interface and its implementations (`WScript` and `Node`) are defined in `system.ts`. You can think of it as the *Operating Environment* (OE).
29
-
30
-
## File: Program
31
-
The compilation context ([a concept we covered previously](docs/project/compilation-context.md)) is represented within the TypeScript compiler as a `Program`.
The compilation context ([a concept we covered previously](docs/project/compilation-context.md)) is represented within the TypeScript compiler as a `Program`. It consists of `SourceFile`s and compiler options.
4
+
5
+
3
6
### Usage of `CompilerHost`
4
7
Its interaction mechanism with the OE:
5
8
@@ -11,7 +14,4 @@ There are other users of `System` as well (e.g. tests).
11
14
12
15
### SourceFile
13
16
14
-
*`SyntaxKind.SourceFile`
15
-
*`interface SourceFile`.
16
-
17
-
The `program` consists of a bunch of source files. A `sourceFile` is actually a top-level AST node as well (`SyntaxKind.SourceFile`). Instances implement `interface SourceFile`.
17
+
The program provides an API to get the Source Files `getSourceFiles(): SourceFile[];`. Each is represented as a root-level node for an AST (called `SourceFile`).
0 commit comments