package parseff
Direct-style parser combinator library for OCaml 5 with zero-copy spans
Install
dune-project
Dependency
Authors
Maintainers
Sources
parseff-0.4.0.tbz
sha256=e0f177f1bccee23e864be017229270932b7505fc2e44d94e55ab4f3a99c84fae
sha512=6405e5a2f04997bcaa5717c7868ce5f3d57989ab3105af9fdc3b98be87f35f5a901ea7375e475466adc3565d3b132159b356e7481924dc2c8fad65e19ad56beb
doc/CHANGES.html
0.4.0
- Breaking: streaming now uses a bounded sliding buffer.
parse_sourceandparse_source_until_endaccept~backtrack_window(default65536) and fail withBacktrack_window_exceeded of backtrack_window_error</code> when a parser needs to keep more input than that for backtracking. This includes a singletake_whileortake_while_spantoken longer than the window. Exhaustive matches on the error type must handle the new case. Raise~backtrack_window` if a parser needs more. - Add
commit.commit ()seals the innermost choice or repetition frame, improving error locality and allowing streaming sources to drop older buffered input earlier. It does not release outer frames: acommitinside theor_ofmany (fun () -> or_ a b ())leaves themanyframe in place. - Breaking: streaming spans may be owned copies.
take_while_spanandsep_by_take_spankeep zero-copy behavior forparse, butparse_sourcemay materialize owned spans so bounded streaming can reclaim old prefixes. - Improve runtime performance and reduce allocation. Parseff now uses a lower-overhead runtime internally, making generic parsers and backtracking-heavy workloads faster while keeping the API largely unchanged.
- Add
peek_char. Provides cheap single-character lookahead without backtracking. - Fix streaming results that differed from
parse.Utf8.take_whileand related scans now report a truncated UTF-8 sequence at the end of input.match_regexnow finds matches that need more than the buffered input, andRe.boland word boundaries see the byte before the current position. - Fix
locationline numbers after backtracking. Lines were counted twice when a parser asked forlocationafter backtracking to an earlier position. match_regexreads ahead in streaming mode. It reads until about half the backtrack window is buffered ahead before it matches, so on an interactive source it waits for that input or the end of the source. A match cannot extend past the window.
0.3.0
- Add
Source.of_seq. Creates a source from astring Seq.t. - Add
Source.of_chunks. Creates a source from a(unit -> string option)pull function. failnow produces.Failure of string</code> instead of <code>Expected- Add
catchcombinator.catch parser handlerintercepts`Failureerrors, allowing recovery within backtracking contexts. - Add
Parseff.Utf8module for Unicode-aware parsing.satisfy,char,any_char,take_while,skip_while,letter,digit,alphanum,whitespaceandtake_while_span. - Add
Parseff.BEandParseff.LEbinary parsing primitives. Big-endian and little-endian readers forany_uint8,any_int8,any_int16,any_uint16,any_int32,any_int64,any_float,any_double, and validatorsint16,int32,int64. - Add
locationandlocation_of_positionfor line/column tracking.location ()returns{ offset; line; col }during parsing (lazy, incremental, zero cost if unused).location_of_position input posconverts a byte offset after parsing — useful for error reporting. - BE/LE exact-match validators produce
.Expected</code> instead of <code>FailureBE.int16,BE.int32,BE.int64(and LE equivalents) are parser expectations, not user validation failures. or_now composes errors from both branches. When both branches fail at the same position,Expectedmessages are joined with" or "(e.g.,expected "foo" or expected "bar"). When branches fail at different positions, the error from the branch that consumed more input is kept. This also improvesone_of, which chainsor_and now naturally produces composed messages across all alternatives.- Register a printer for
Unhandled effects, warning the user about bad organitzation of the parser function
0.2.0
- Unified
*1variants into base combinators with~at_leastparameter.many1→many ~at_least:1,take_while1→take_while ~at_least:1,sep_by1→sep_by ~at_least:1,end_by1→end_by ~at_least:1,whitespace1→whitespace ~at_least:1. The~at_leastparameter generalizes beyond the binary zero-vs-one distinction (e.g.,many ~at_least:3requires at least three matches). The oldchainl1andchainr1were also removed in favor of making thedefaultargument optional (see next item). - Renamed
chainl/chainrtofold_left/fold_rightwith~otherwise.chainl1 p op→fold_left p op,chainl p op default→fold_left p op ~otherwise:default, and likewise forchainr/fold_right. The new names better describe what the combinators do (parse and fold with associativity) and align with OCaml'sList.fold_left/List.fold_rightnaming conventions. The~otherwiselabeled argument replaces the old positionaldefaultparameter, providing a fallback value when zero elements match.
0.1.0
Initial release of Parseff