Skip to content

Commit 5487c02

Browse files
authored
docs(tutorial): refine terminology and clarify syntax node definitions (#8)
- Update repetition syntax description to use 'matcher | transcriber' for clarity. - Clarify that `parse_macro_input!` supports custom syntax tree nodes. - Simplify the definition of syntax tree nodes in `syntax_tree.md`.
1 parent 758d76a commit 5487c02

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/macros_1.0/repetitions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Repetitions
22

3-
We use `$(<metavariable>)[delimiter]<*|?|+>` to specify metavariable repetition in both the pattern (matcher) and the expansion (transcriber).
3+
We use `$(<matcher | transcriber>)[delimiter]<*|?|+>` to specify metavariable repetition in both the pattern (matcher) and the expansion (transcriber).
44

55
- `*`: Zero or more times
66
- `?`: Zero or one time

src/procedural_macros/proc_macro_crates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn main() {
5959
The `input` contains the tokens enclosed by whatever delimiters (parentheses `()`, brackets `[]`, or braces `{}`) are used when calling the macro. In the example above, the input is `world`. Upon expansion, the call `hello_macro!(world)` is replaced entirely by the macro's `output`.
6060

6161
### The `parse_macro_input!` Macro
62-
The `parse_macro_input!` macro parses the input `TokenStream` into a specific `syn` syntax tree node. If parsing fails, it automatically generates a high-quality compile-time error.
62+
The `parse_macro_input!` macro parses the input `TokenStream` into a specific `syn` syntax tree node (including custom syntax tree nodes). If parsing fails, it automatically generates a high-quality compile-time error.
6363

6464
The basic syntax is `parse_macro_input!(<TokenStream> as <Type>)`. This convenience macro is specifically designed for use within `proc-macro` crates.
6565

src/procedural_macros/syntax_tree.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A syntax tree is a hierarchical representation of source code. It transforms a flat, linear stream of tokens into a structured format that is easy to process and manipulate. The `syn` crate provides a complete syntax tree that can represent any valid Rust source code. We can use `syn` to define our own syntax trees; for example, we can define a syntax tree for HTML, CSS, or any other DSL.
44

5-
A syntax tree is made up of syntax tree nodes. A syntax tree node can be a token, a group of tokens, or a value of a type that implements the `syn::parse::Parse` trait.
5+
A syntax tree is made up of syntax tree nodes. A syntax tree node can be a token, a group of tokens, or any type that implements the `syn::parse::Parse` trait.
66

77
## See a Syntax Tree Node in Action
88

0 commit comments

Comments
 (0)