rust-lang / rust-lang/rustc-dev-guide
"The parser"
Open
Nobody has claimed this yet.
A-AST
A-lexing
A-parser
C-enhancement
E-hard
E-help-wanted
T-compiler
- Dominant language
- HTML
- Stars
- 1.9k
- Forks
- 613
- Avg merge
- 17h 24m
- Merged PRs (30d)
- 39
Description
It'd be worth covering
- where the lexer is
- how the parser works
- conventions around error recovery
- - What is this
eatfunction?- It consumes a token, and queues up the next token as lookahead
- How do you handle identifiers and keywords?
- What about constructing spans?
- (quoting Niko from below) I have to bring this back into cache, but in general there is this
last_spanthing that stores the span of the last token, and many things follow the idiom of saving the "lo" point of the span, parsing some stuff, then extracting the "hi" point and combining them. This would be used to make a span that encompasses, for example, an entiretraitdefinition (the lo point would come from thetraitkeyword, but the end point comes after having parsed a bunch of other things).
- (quoting Niko from below) I have to bring this back into cache, but in general there is this
- What is this crazy pretty printer?
- It dumps out the AST in human readable form.
- We have tests that will parse each file in run-pass, pretty print it, and then test that the resulting pretty printed file type checks, so you have to implement this.
- Something like this: https://github.com/rust-lang-nursery/rustc-guide/issues/13#issuecomment-361848936 and https://github.com/rust-lang-nursery/rustc-guide/issues/13#issuecomment-361992949
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the rust-lang/rust parser.rs reference linked in the issue and the existing run-pass pretty-print tests. Document the lexer, parser flow, error recovery, eat, identifiers and keywords, span construction, and AST pretty printer, including how the tests validate printed output.】【。
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100