Skip to content

Add AST to the glossary #23537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2015
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
8 changes: 5 additions & 3 deletions src/doc/trpl/advanced-macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ off.
# Syntactic requirements

Even when Rust code contains un-expanded macros, it can be parsed as a full
syntax tree. This property can be very useful for editors and other tools that
process code. It also has a few consequences for the design of Rust's macro
system.
[syntax tree][ast]. This property can be very useful for editors and other
tools that process code. It also has a few consequences for the design of
Rust's macro system.

[ast]: glossary.html#abstract-syntax-tree

One consequence is that Rust must determine, when it parses a macro invocation,
whether the macro stands in for
Expand Down
23 changes: 23 additions & 0 deletions src/doc/trpl/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,26 @@ let z = (8, 2, 6);
```

In the example above `x` and `y` have arity 2. `z` has arity 3.

### Abstract Syntax Tree
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could include the 'AST' abbreviation (not necessarily in the title, but somewhere).


When a compiler is compiling your program, it does a number of different
things. One of the things that it does is turn the text of your program into an
'abstract syntax tree,' or 'AST.' This tree is a representation of the
structure of your program. For example, `2 + 3` can be turned into a tree:

```text
+
/ \
2 3
```

And `2 + (3 * 4)` would look like this:

```text
+
/ \
2 *
/ \
3 4
```