package wax-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4361e1324b7754a4c08ab5b505df32061f3ce0cea60443fd0d3699e0fa796b32
sha512=fcc756d2f160ba90a9aa1131f2ab22ed7f45466ccd658c21cf9df6868a6aab0cee7f404719d698a379958802f9820398f2fe0685ecc4dda018ca4f653294e39b
doc/wax-lib.utils/Wax_utils/Parser_error_runtime/index.html
Module Wax_utils.Parser_error_runtimeSource
Runtime resolution of the <N> / <^N> markers stele's generated messages carry.
A stele-generated message may embed marker lines of two kinds, both anchored at a 1-based stack cell index N resolved against the running parser:
- a delimiter hint
<N>This '(' opens the enclosing construct.— underlines the opening delimiter of the construct at cellN, spanning the full alias the label names (one character for a plain(, both characters of a compound opener like[|); - a hedge subject
<^N>this expression— underlines the whole construct that cellNproduced, the one a hedge ("Assuming that the X is complete, …") assumes finished.
Resolving either needs the running parser's environment, so the generator (a build-time tool) cannot do it — the adopter's error handler must, at the point it holds the incremental engine's env. This library is that resolution, extracted once so every adopter shares the subtle half (the walk-back-over-blanks-to-the-opening-delimiter refinement, the epsilon subject handling) rather than reimplementing it.
A consumer reading an older generator's output sees only <N> markers; a generator carrying <^N> markers stays readable to a resolver that predates them (the ^-tagged depth fails the plain integer parse and the line is left inline), so the marker vocabulary extends compatibly.
It depends on menhirLib and the standard library only, so it compiles under wasm_of_ocaml / js_of_ocaml as well as native.
The minimal slice of a Menhir INCREMENTAL_ENGINE the resolution needs: reaching a stack cell by depth and reading its source span. Instantiate it from the parser's MenhirInterpreter — get is MenhirInterpreter.get and positions destructures MenhirInterpreter.Element.