Skip to main content

Module shared

Module shared 

Source
Expand description

Shared parser span conversion helpers.

Functions§

opt_span
Returns None (skipping O(n) string scans) when position tracking is disabled, or Some(span) with real line/column data when enabled.
opt_span_range
Like opt_span but takes a start/end range using exclusive end semantics.
opt_span_range_inclusive
Like opt_span but takes a start/end range using inclusive end semantics.
to_parser_span
Convert grammar span (LocatedSpan) to parser span (line/column)
to_parser_span_range
Convert grammar span range (start, end) to parser span Convert a grammar span range where end is the remainder span (i.e. the nom rest after a match). This sets the end position to the end.location_offset() (start of the remainder), matching inline parser usage patterns like to_parser_span_range(start, rest).
to_parser_span_range_inclusive
Convert a grammar span range where end is the final fragment of the matched range (i.e. inclusive). This preserves the previous block-level semantics where callers pass the last fragment and expect the end to be at end.location_offset() + end.fragment().len().

Type Aliases§

GrammarSpan
Grammar span type (nom_locate::LocatedSpan)