Module parse

Source

Structs§

Binding
Records a single binding, used when parsing [Binder].
ParseError
Tracks an error that occurred while parsing. The parse error records the input text it saw, which will be some suffix of the original input, along with a message.
Scope
Tracks the variables in scope at this point in parsing.

Traits§

CoreParse
Trait for parsing a Term<L> as input.

Functions§

expect_char
Consume next character and require that it be ch.
expect_keyword
Consume next identifier, requiring that it be equal to expected.
identifier
Extracts a maximal identifier from the start of text, following the usual rules.
number
Extract a number from the input, erroring if the input does not start with a number.
reject_keyword
Reject next identifier if it is the given keyword. Consumes nothing.
require_unambiguous
Used at choice points in the grammar. Iterates over all possible parses, looking for a single successful parse. If there are multiple successful parses, that indicates an ambiguous grammar, so we panic. If there are no successful parses, tries to come up with the best error it can: it prefers errors that arise from “partially successful” parses (e.g., parses that consume some input before failing), but if there are none of those, it will give an error at text saying that we expected to find a expected.
skip_trailing_comma
Consume a comma if one is present.
skip_whitespace
Skips leading whitespace and comments.
try_parse
Convenience function for use when generating code: calls the closure it is given as argument. Used to introduce new scope for name bindings.

Type Aliases§

ParseResult