Skip to content

Commit 8960d2a

Browse files
committed
---
yaml --- r: 30072 b: refs/heads/incoming c: 9297d1f h: refs/heads/master v: v3
1 parent ab03888 commit 8960d2a

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 7669032dd377d6207c4d78e52c9e858e2f2d4180
9+
refs/heads/incoming: 9297d1f00a27ac6bb272d5b2b75535697f1e2e4b
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/doc/rust.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ matches, in a structure that mimics the structure of the repetition
522522
encountered on a successful match. The job of the transcriber is to sort that
523523
structure out.
524524

525-
The rules for transcription of these repetitions are called "Macro By Example". Essentially, one "layer" of repetition is discharged at a time, and all of
525+
The rules for transcription of these repetitions are called "Macro By Example".
526+
Essentially, one "layer" of repetition is discharged at a time, and all of
526527
them must be discharged by the time a name is transcribed. Therefore,
527528
`( $( $i:ident ),* ) => ( $i )` is an invalid macro, but
528529
`( $( $i:ident ),* ) => ( $( $i:ident ),* )` is acceptable (if trivial).
@@ -537,6 +538,20 @@ transcribes to `( (a,d), (b,e), (c,f) )`.
537538

538539
Nested repetitions are allowed.
539540

541+
### Parsing limitations
542+
543+
The parser used by the macro system is reasonably powerful, but the parsing of
544+
Rust syntax is restricted in two ways:
545+
546+
1. The parser will always parse as much as possible. If it attempts to match
547+
`$i:expr [ , ]` against `8 [ , ]`, it will attempt to parse `i` as an array
548+
index operation and fail. Adding a separator can solve this problem.
549+
2. The parser must have eliminated all ambiguity by the time it reaches a
550+
`$` _name_ `:` _designator_. This most often affects them when they occur in
551+
the beginning of, or immediately after, a `$(...)*`; requiring a distinctive
552+
token in front can solve the problem.
553+
554+
540555
## Syntax extensions useful for the macro author
541556

542557
* `log_syntax!` : print out the arguments at compile time

branches/incoming/doc/tutorial.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,8 +2481,9 @@ Macros, as currently implemented, are not for the faint of heart. Even
24812481
ordinary syntax errors can be more difficult to debug when they occur inside
24822482
a macro, and errors caused by parse problems in generated code can be very
24832483
tricky. Invoking the `log_syntax!` macro can help elucidate intermediate
2484-
states, and using `--pretty expanded` as an argument to the compiler will
2485-
show the result of expansion.
2484+
states, using `trace_macros!(true)` will automatically print those
2485+
intermediate states out, and using `--pretty expanded` as an argument to the
2486+
compiler will show the result of expansion.
24862487

24872488
# Traits
24882489

0 commit comments

Comments
 (0)