package wax-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4361e1324b7754a4c08ab5b505df32061f3ce0cea60443fd0d3699e0fa796b32
sha512=fcc756d2f160ba90a9aa1131f2ab22ed7f45466ccd658c21cf9df6868a6aab0cee7f404719d698a379958802f9820398f2fe0685ecc4dda018ca4f653294e39b
doc/wax-lib.utils/Wax_utils/Parsing/index.html
Module Wax_utils.ParsingSource
Generic parsing utilities.
type syntax_error = {location : Ast.location;message : Message.t;hint : Message.t option;fix : Diagnostic.edit option;
}A syntax error, both the payload of Syntax_error and the value parse_diagnostics / parse_recover return: the location range, the human-readable message, any related labels (e.g. the matching opening delimiter), an optional prose hint, and an optional machine-applicable quick fix (a text edit, reusing Diagnostic.edit so a syntax error's fix flows through the same editor/LSP code-action path as the typer's suggestions). Recovery derives a fix mechanically from an insertion repair (see Make.parse_recover).
Raised when a syntax error occurs, carrying the structured payload above.
val syntax_error :
location:Ast.location ->
?related:Diagnostic.label list ->
?hint:Message.t ->
?fix:Diagnostic.edit ->
Message.t ->
'asyntax_error ~location ?related ?hint ?fix message raises Syntax_error with the structured payload. Smart constructor used by every enriched raise site (the lexers and both grammars), so the payload shape is spelled once.
syntax_error_pair ((loc_start, loc_end), message) builds (without raising) the Syntax_error value from the legacy position-pair payload, with no related/hint/fix. It keeps the many pre-existing raise (Syntax_error (pair, msg)) sites in the lexers and grammars a one-token change; new code should prefer the raising syntax_error.
type sync_class = | Open| Close| Boundary| Leader| Terminal| Skip(*How the panic-mode recovery of
Make.parse_recovertreats a token when it is scanning for a place to resynchronize. The skip is nesting-aware: it tracks the bracket depth entered while skipping so a boundary belonging to a group opened inside the skipped span does not resynchronize the enclosing construct.Open— an opening bracket. Descends one nesting level; never itself a resync point.Close— a closing bracket. At the outer level (depth 0) it is a resync point closing an enclosing construct; otherwise it ascends one level (matching anOpenmet while skipping) and scanning continues.Boundary— a non-bracket resync point (typically a statement separator), counted only at the outer level, like aClose. Recovery stops there, unwinds the parser stack to the closest state that can shift it, shifts it, and resumes.Leader— a resync point valid at any depth: an item/statement-leading keyword. Recovery stops at one even inside an unbalanced opener, so a stray bracket cannot swallow the next top-level item.Terminal— the end-of-input token. Recovery stops at it but never discards it; if no stacked state can accept it, parsing gives up (the best-effort AST is then absent).Skip— anything else: discarded while scanning for the next boundary.
module Make
(Output : sig ... end)
(Tokens : sig ... end)
(_ : sig ... end)
(_ : sig ... end)
(_ : sig ... end) :
sig ... endCore parser over a Menhir incremental API, without the fast parser. The incremental parser produces both the AST and, via Parser_messages, the error in a single pass, so this is all an in-process consumer that only wants parse_diagnostics needs. See Make_parser for the fast-path variant.