-
-
Notifications
You must be signed in to change notification settings - Fork 723
Closed
Labels
A-parserArea - ParserArea - ParserE-Help WantedExperience level - For the experienced collaboratorsExperience level - For the experienced collaborators
Description
This is a follow-up to #11194.
Now that we are using lookahead in more places in the parser (which is a relatively expensive operation), we want to ensure that we call it as little as possible. Similarly, we also want to avoid try_parse whenever possible. This can be achieved in a few different ways:
- Add a fast check before doing lookahead
- Example:
self.is_ts && self.lookahead(...)for checking TypeScript-specific syntax - Example:
self.at(Kind::LCurly) && self.lookahead(...)for checking for a keyword that is only ever preceded by a few specific tokens
- Example:
- Only parse forwards: remove backtracking
- Ideally, we only ever need to look at a single token at a time in order to get the AST. This might not be possible everywhere currently but there are surely some functions that can be written in this way. In code this looks only using
eat,at,bump,bump_anymethods, and other similar functions and not using:rewind,checkpoint,try_parse, andlookahead.
- Ideally, we only ever need to look at a single token at a time in order to get the AST. This might not be possible everywhere currently but there are surely some functions that can be written in this way. In code this looks only using
Metadata
Metadata
Assignees
Labels
A-parserArea - ParserArea - ParserE-Help WantedExperience level - For the experienced collaboratorsExperience level - For the experienced collaborators