|
1 | 1 | # Syntax and the AST
|
2 | 2 |
|
3 | 3 | Working directly with source code is very inconvenient and error-prone. Thus,
|
4 |
| -before we do anything else, we convert raw source code into an AST. It turns |
5 |
| -out that doing even this involves a lot of work, including lexing, parsing, |
6 |
| -macro expansion, name resolution, conditional compilation, feature-gate |
7 |
| -checking, and validation of the AST. In this chapter, we take a look at all |
8 |
| -of these steps. |
| 4 | +before we do anything else, we convert raw source code into an [Abstract Syntax |
| 5 | +Tree (`AST`)][`AST`]. It turns out that doing even this involves a lot of work, |
| 6 | +including [lexing, parsing], [`macro` expansion], [name resolution], conditional |
| 7 | +compilation, [feature-gate checking], and [validation] of the [`AST`]. In this chapter, |
| 8 | +we take a look at all of these steps. |
9 | 9 |
|
10 | 10 | Notably, there isn't always a clean ordering between these tasks. For example,
|
11 |
| -macro expansion relies on name resolution to resolve the names of macros and |
12 |
| -imports. And parsing requires macro expansion, which in turn may require |
13 |
| -parsing the output of the macro. |
| 11 | +`macro` expansion relies on name resolution to resolve the names of `macro`s and |
| 12 | +imports. And parsing requires `macro` expansion, which in turn may require |
| 13 | +parsing the output of the `macro`. |
| 14 | + |
| 15 | +[`AST`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/index.html |
| 16 | +[`macro` expansion]: ./macro-expansion.md |
| 17 | +[feature-gate checking]: ./feature-gate-ck.md |
| 18 | +[lexing, parsing]: ./lexing-parsing.md |
| 19 | +[name resolution]: ./name-resolution.md |
| 20 | +[validation]: ./ast-validation.md |
0 commit comments