Expand description
Recursive-descent parser producing the AST, modelled on rustc_parse.
- The parser walks the token list keeping
token(current) andprev_token; a node’s span islo.to(self.prev_token.span). check,eatandexpectrecord what would have been accepted at the current position, so errors read “expected one of,or), found;”.- Parsing functions return
PResult. Recovery points (items and statements) report the error, skip ahead and carry on, leaving anErrnode in the tree.
Structs§
Enums§
- Path
Style - Where a path appears, which decides how generic arguments are written
(rustc’s
PathStyle).
Functions§
- parse_
file - Lexes and parses a whole source file, returning the module (complete
even if there were errors, with
Errnodes where parsing failed) and every diagnostic. Node ids are taken fromids. - parse_
items - Parses
sourceas module-level items. A synthetic file is added tosource_mapso that diagnostics can point into the generated code.
Type Aliases§
- PResult
- The result of a parsing function. The error has not been reported yet: the caller either reports it or propagates it to a recovery point.