Skip to content

Commit ecdf792

Browse files
committed
Auto merge of rust-lang#23537 - steveklabnik:gh22551, r=alexcrichton
Fixes rust-lang#22551 ('grammar' wasn't really used in the chapter at all)
2 parents cbc660b + af09763 commit ecdf792

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/doc/trpl/advanced-macros.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ off.
66
# Syntactic requirements
77

88
Even when Rust code contains un-expanded macros, it can be parsed as a full
9-
syntax tree. This property can be very useful for editors and other tools that
10-
process code. It also has a few consequences for the design of Rust's macro
11-
system.
9+
[syntax tree][ast]. This property can be very useful for editors and other
10+
tools that process code. It also has a few consequences for the design of
11+
Rust's macro system.
12+
13+
[ast]: glossary.html#abstract-syntax-tree
1214

1315
One consequence is that Rust must determine, when it parses a macro invocation,
1416
whether the macro stands in for

src/doc/trpl/glossary.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,26 @@ let z = (8, 2, 6);
1414
```
1515

1616
In the example above `x` and `y` have arity 2. `z` has arity 3.
17+
18+
### Abstract Syntax Tree
19+
20+
When a compiler is compiling your program, it does a number of different
21+
things. One of the things that it does is turn the text of your program into an
22+
'abstract syntax tree,' or 'AST.' This tree is a representation of the
23+
structure of your program. For example, `2 + 3` can be turned into a tree:
24+
25+
```text
26+
+
27+
/ \
28+
2 3
29+
```
30+
31+
And `2 + (3 * 4)` would look like this:
32+
33+
```text
34+
+
35+
/ \
36+
2 *
37+
/ \
38+
3 4
39+
```

0 commit comments

Comments
 (0)