Skip to content
Merged
Changes from 1 commit
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
15 changes: 14 additions & 1 deletion src/the-parser.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# The parser
# The Parser

The parser is responsible for converting raw Rust source code into a structured
form which is easier for the compiler to work with, usually called an *Abstract
Syntax Tree*. The bulk of the parser lives in the [libsyntax] crate.
Copy link
Contributor

Choose a reason for hiding this comment

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

Link to wikipedia? Maybe pointless?


The parsing process is made up of roughly 3 stages,

- lexical analysis - turn a stream of characters into a stream of token trees
- macro expansion - run `proc-macros` and expand `macro_rules` macros
- parsing - turn the token trees into an AST
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I think I would link to the relevant chapter of the guide -- oh, wait, do we not have a chapter for the AST? We should add one =)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking the AST would fall under the parser section, maybe as a short sub-chapter.



[libsyntax]: https://github.com/rust-lang/rust/tree/master/src/libsyntax