package stele

  1. Overview
  2. Docs
User-friendly syntax-error messages for any Menhir grammar

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.1.0.tar.gz
md5=4a2c12c3a90d763a7c2c7d1a6982493c
sha512=f9004a4c4d999d8b71a3f7178ac72bd48574f2c9f4bfcaff4c6e5b2031d015bfc64b4cd02848e34054e841dac142befdd8cd5938c061dc9f7c9fc417c2176837

doc/stele.runtime/Parser_error_runtime/Make/index.html

Module Parser_error_runtime.MakeSource

Parameters

module E : ENGINE

Signature

Sourcetype label = {
  1. loc_start : Lexing.position;
  2. loc_end : Lexing.position;
  3. text : string;
}

A resolved marker and its own label text (the marker prefix and its bounds removed): a delimiter hint gives a span at the opening delimiter as wide as the alias its label names (one character for a plain (, two for a compound [|), a hedge subject the whole construct's true span (rendered as a multi-line spine when it crosses several lines).

Sourceval resolve : source:string -> env:'a E.env -> string -> string * label list

resolve ~source ~env message post-processes a stele-generated message against the error environment env and the whole source text source: it expands any Menhir $i source-slice references, then turns each marker line into a label:

  • <N>… anchors at the N-th stack cell's opening delimiter (walking back over blanks and line breaks to the ( / [ / { when the cell's own start is not itself the delimiter);
  • <^N>… anchors across the N-th stack cell's full span (the whole construct, however many lines it crosses), and dropped when that span is zero-width (an epsilon reduction — no construct to point at).

Returns the main message (marker lines removed) and the located labels in the order the markers appear (subject before delimiter hint, matching the generator's emission). A marker whose depth exceeds the live stack, or whose depth field it does not recognise (anything but decimal digits, after an optional ^), is left inline in the main message.