Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/macros_1.0/repetitions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Repetitions

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

- `*`: Zero or more times
- `?`: Zero or one time
Expand Down
2 changes: 1 addition & 1 deletion src/procedural_macros/proc_macro_crates.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn main() {
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`.

### The `parse_macro_input!` Macro
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.
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.

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

Expand Down
2 changes: 1 addition & 1 deletion src/procedural_macros/syntax_tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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.

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.
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.

## See a Syntax Tree Node in Action

Expand Down