1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Macro argument patterns in Rust:
*
* - `$(...)*`: 0 or more arguments, **without separator**. Example: `debug!(foo, bar, baz)`.
* - `$(...),*`: 0 or more arguments, **separated by commas**. Example: `debug!(foo, bar, baz,)`.
* - `$(...);*`: 0 or more arguments, **separated by semicolons**. Example: `debug!(foo; bar; baz;)`.
* - `$(...)+`: 1 or more arguments, **without separator**. Example: `debug!(foo bar baz)`.
* - `$(...),+`: 1 or more arguments, **separated by commas**. Example: `debug!(foo, bar, baz)`.
* - `$(...);+`: 1 or more arguments, **separated by semicolons**. Example: `debug!(foo; bar; baz)`.
* - `$(...)?`: 0 or 1 argument, **without separator**. Example: `debug!(foo)`.
* - `$(...),?`: 0 or 1 argument, **separated by commas**. Example: `debug!(foo,)`.
* - `$(...);?`: 0 or 1 argument, **separated by semicolons**. Example: `debug!(foo;)`.
*/
/*
* `$x` represents the argument inside the pattern.
*
* Example:
* - `$x:expr` can be an expression.
* - `$x:literal` can be a literal value.
*/
/*
* Token types:
*
* - `expr`: Any valid Rust expression. It can be followed by `=>`, `,`, or `;` depending on the macro's syntax.
* - `literal`: A literal value, such as a number or string, which may be followed by any other tokens.
* - `tt` (token tree): Represents a **generic sequence of tokens**. This is the most flexible and powerful token type,
* allowing any valid Rust syntax
*/