Module formality_core::parse

source ·

Structs

  • Records a single binding, used when parsing [Binder].
  • 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.
  • Tracks the variables in scope at this point in parsing.

Traits

Functions

  • Consume next character and require that it be ch.
  • Consume next identifier, requiring that it be equal to expected.
  • Extracts a maximal identifier from the start of text, following the usual rules.
  • Extract a number from the input, erroring if the input does not start with a number.
  • Reject next identifier if it is the given keyword. Consumes nothing.
  • 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.
  • Consume a comma if one is present.
  • Skips leading whitespace and comments.
  • 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