summaryrefslogtreecommitdiffstats
path: root/src/doc/rustc-dev-guide/src/the-parser.md
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
commit17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch)
tree3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /src/doc/rustc-dev-guide/src/the-parser.md
parentAdding upstream version 1.64.0+dfsg1. (diff)
downloadrustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.tar.xz
rustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.zip
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/doc/rustc-dev-guide/src/the-parser.md')
-rw-r--r--src/doc/rustc-dev-guide/src/the-parser.md17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/doc/rustc-dev-guide/src/the-parser.md b/src/doc/rustc-dev-guide/src/the-parser.md
index ff43220c1..0d37704e8 100644
--- a/src/doc/rustc-dev-guide/src/the-parser.md
+++ b/src/doc/rustc-dev-guide/src/the-parser.md
@@ -1,6 +1,6 @@
# Lexing and Parsing
-As of <!-- date: 2021-01 --> January 2021, the lexer and parser are undergoing
+As of <!-- date-check --> January 2021, the lexer and parser are undergoing
refactoring to allow extracting them into libraries.
The very first thing the compiler does is take the program (in Unicode
@@ -35,9 +35,10 @@ The main entrypoint to the parser is via the various `parse_*` functions and oth
the token stream, and then execute the parser to get a `Crate` (the root AST
node).
-To minimise the amount of copying that is done, both the `StringReader` and
-`Parser` have lifetimes which bind them to the parent `ParseSess`. This contains
-all the information needed while parsing, as well as the `SourceMap` itself.
+To minimize the amount of copying that is done,
+both [`StringReader`] and [`Parser`] have lifetimes which bind them to the parent `ParseSess`.
+This contains all the information needed while parsing,
+as well as the [`SourceMap`] itself.
Note that while parsing, we may encounter macro definitions or invocations. We
set these aside to be expanded (see [this chapter](./macro-expansion.md)).
@@ -52,9 +53,9 @@ Code for lexical analysis is split between two crates:
constituting tokens. Although it is popular to implement lexers as generated
finite state machines, the lexer in `rustc_lexer` is hand-written.
-- [`StringReader`] from [`rustc_ast`][rustc_ast] integrates `rustc_lexer` with `rustc`
- specific data structures. Specifically, it adds `Span` information to tokens
- returned by `rustc_lexer` and interns identifiers.
+- [`StringReader`] integrates `rustc_lexer` with data structures specific to `rustc`.
+ Specifically,
+ it adds `Span` information to tokens returned by `rustc_lexer` and interns identifiers.
[rustc_ast]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/index.html
[rustc_errors]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/index.html
@@ -64,7 +65,7 @@ Code for lexical analysis is split between two crates:
[rustc_parse]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/index.html
[parser_lib]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/index.html
[parser]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/index.html
-[`Parser`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/parse/parser/struct.Parser.html
+[`Parser`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html
[`StringReader`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/lexer/struct.StringReader.html
[visit module]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/visit/index.html
[sourcefile]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/struct.SourceFile.html