All notable changes to Parseff. See all releases on GitHub.
0.6.0
- [BREAKING]
fail,errorandwarnraiseInvalid_argumenton a note whoseathas a negativestartorstop, and swapstartandstopwhenstart > stop, as they do for~fromand~upto;render_errorprinted such notes at the wrong place (#141) (@davesnx) - [BREAKING] Add
Push.cancelto end an unfinished push parse and release itsRefcells and~diagnosticscollector;Push.parse_eachreturns itspushfunction with acancelfunction, takes?pendingasSource.parse_eachdoes, and its steps use the names ofPush.parse:Need_inputisAwaitandError_ofisError(#139) (@davesnx) - [BREAKING] End
Source.parse_eachwithErrorwhen a~pendingrun consumes no input twice in a row at the same position, so apendingthat never returnsfalsecannot make the sequence endless;Push.parse_eachfollows the same rule (#139) (@davesnx) - [BREAKING] Raise
Invalid_argumenton invalid arguments instead of clamping them: a negative~at_leastontake_while,many,sep_by,end_by,Iter.many,Iter.sep_by,whitespace,Utf8.take_whileandUtf8.whitespace; a~max_depthbelow 1 onparse,Source.parse,Source.parse_each,Push.parseandPush.parse_each; a negative~fromor~uptoonfail,errorandwarn; a negativenoncount; and aposoutside the input onlocation_of_position(#138) (@davesnx) - [BREAKING]
skip_nestedcloses a pair with the same opening and closing byte, such as('"', '"'), when that byte matches the innermost open bracket, instead of opening a new level each time (#138) (@davesnx) - [BREAKING] Keep the bytes
Source.parseandSource.parse_eachread but did not consume, so the next parse of the same source starts after the consumed input, where the parser failed after anError, or where it was when an exception left it;Source.of_stringcontinues the same way instead of restarting at offset 0, andSource.offsetgives the absolute offset where the next parse starts (#131) (@davesnx) - [BREAKING] Read diagnostics in source order:
Diagnostics.to_listand theinnerlist given to~keepsort bypos, and entries at the same position keep the order they were recorded in (#128) (@davesnx) - [BREAKING] Name every runner
parse:parse_sourceisSource.parse, and the push runners move into the new modulePush(#113) (@davesnx) - [BREAKING] Polish the API: combinators run with no trailing
(), spans move intoSlice,fold_leftandfold_righttake?otherwisefirst, andliteraltakes?case_sensitive(#112) (@davesnx) - [BREAKING] Change the error and recovery API before 1.0:
recover,requireandlistuse the collector of the runner,Limit_exceededis anerror_kind, andlocation.colisbyte_col(#110) (@davesnx) - [BREAKING] Let
warnrecord acustom_errorinto the collector of the runner, so a recovering parser can warn;warn_atis removed (#102) (@davesnx) - [BREAKING] Remove
regexandmatch_regex, and drop theredependency (#100) (@davesnx) - [BREAKING] Rename
consumetoliteraland returnunit(#98) (@davesnx) - [BREAKING] Settle the API before 1.0:
failbacktracks aserrordoes,spanis abstract,locationis private,digitreturns achar,satisfytakes?labelfirst,FailureisFailed,skip_while_then_charandfused_sep_takeare removed, and errors compare by their fields; also addPush,Iter.many,Iter.take,within,?at_most,Source.of_bigstring_chunks,requireandlist(#76) (@davesnx) - [FEATURE] Group the streaming combinators in
Parseff.Iter:Iter.many,Iter.sep_by,Iter.takeandIter.take_while, with oneunstablealert on the module (#137) (@davesnx) - [FEATURE] Make
~at_moststable ontake_while,take_until,skip_untilandmany: exceeding it fails withLimit_exceeded { limit = at_most }, never a silent cap, and the failure is fatal likecut (); fail, so an enclosingor_,optionalor repetition does not try another option (look_ahead,peek_withandcapturestill stop it, as they stopcut);take_untilandskip_untilgiveLimit_exceededwhenever more thanat_mostbytes remain without the terminator;at_most < 0orat_most < at_leastraisesInvalid_argument(#142) (@davesnx) - [FEATURE] Add
?at_mosttoSlice.take_while,skip_while,Utf8.take_while,Utf8.Slice.take_while,Utf8.skip_while,sep_byandend_by, counting bytes, code points or elements as their?at_leastdoes (#142) (@davesnx) - [FEATURE] Add
?at_leastand?labeltoSlice.take_while,skip_while,Utf8.Slice.take_whileandUtf8.skip_while, failing astake_whileandUtf8.take_whiledo and raisingInvalid_argumenton a negative~at_least(#140) (@davesnx) - [FEATURE] Make
Push.parse,Push.feedandPush.finishstable, keep the chunks not yet fed afterDonein thePushexample, and state what 0.x releases promise and how to show theunstablealert (#127) (@davesnx) - [FEATURE] Add
Push.parse_each, a push parse of a stream of values in one fiber (#111) (@davesnx) - [FEATURE] Add
not_followed_by(#107) (@davesnx) - [FEATURE] Pass a
Charsettotake_while,skip_while,Slice.take_whileandIter.take_whileas?set(#104) (@davesnx) - [FEATURE] Add
identifierandis_ident_char(#103) (@davesnx) - [FEATURE] Add
take_untilandskip_untilfor a string terminator (#97) (@davesnx) - [FEATURE] Recover only where no open choice surrounds the recovery, and make the recovery functions stable:
listreplacessep_by_recover,~keepreplacescapture_withand~record, and~contextsreplaces~outer(#95) (@davesnx) - [FEATURE] Add
~recordtorecoverandsep_by_recover, and~outertocaptureandrecover(#70) (@davesnx) - [FEATURE] Add
?initial_buffer_sizetoSource.of_function, and grow its read buffer at the next read (#57) (@davesnx) - [FEATURE] Add
~releasetocaptureandrecover:commitandcutmove the rewind point (#56) (@davesnx) - [FEATURE] Add
context ~start(#55) (@davesnx) - [FEATURE] Add
capture_withand document the rule for recorded errors (#54) (@davesnx) - [FEATURE] Add
sep_by_recoverandskip_nestedfor lists that recover per element (#53) (@davesnx) - [FEATURE] Add
peek_withandskip_to: read a lookahead token once (#52) (@davesnx) - [FEATURE] Add
precedence: operator precedence with one lookup per operand (#51) (@davesnx) - [FEATURE] Add
?pendingtoSource.parse_eachfor a value held in a lookahead (#50) (@davesnx) - [FEATURE] Add
~helptofailanderror, printed as a help line byrender_error(#49) (@davesnx) - [FEATURE] Add
?uptotofailanderror(#48) (@davesnx) - [FEATURE] Rename the
atomargument ofexpressiontooperand(#42) (@davesnx) - [FEATURE] Rename
int,floatandhex_inttointeger,numberandhex_integer(#39) (@davesnx) - [FEATURE] Add
Ref, arefthat rolls back when the parser backtracks (#33) (@davesnx) - [FEATURE] Add
expression, an operator table for precedence parsing (#32) (@davesnx) - [FEATURE] Add
int,floatandhex_int(#31) (@davesnx) - [FEATURE] Add trace mode for context events (#30) (@davesnx)
- [FEATURE] Add
with_range,recognizeandSlice.recognize(#29) (@davesnx) - [FEATURE] Add
Source.parse_eachto parse many values from one source (#28) (@davesnx) - [FEATURE] Add
lexemeandkeyword(#27) (@davesnx) - [FEATURE] Add
any_uint32,any_varintandSlice.take(#26) (@davesnx) - [FEATURE] Add
captureandrecoverfor error recovery (#24) (@davesnx) - [FIX]
many ~at_mostreportsLimit_exceeded { limit = at_most }after arecoverinside an element replays the loop, instead of the limit left over from the replay (#142) (@davesnx) - [FIX] A failed
skip_untilleaves the position at the same place inparse,Source.parseandPush.parse, so traceFailevents agree across runners (#142) (@davesnx) - [FIX]
render_errorprintshelp: raise ~max_depthfor arec_depth error when~max_depthequals thefold_rightstack limit (#138) (@davesnx) - [FIX] Stop
expressionfrom looping when one level lists the same operator value twice and that operator fails after it reads its token (#135) (@davesnx) - [FIX] A
commitin a nestedexpressionoperator fails only that operator, so the enclosing operator tries the next one, as property fuzzing found (#126) (@davesnx) - [FIX] Fix commit sealing and error positions found by property fuzzing: a
commitinfold_rightor in a required element ofmanyno longer seals the wrong frame (#121) (@davesnx) - [FIX] Read the longest valid number in
number, and fail when it is out of float range (#99) (@davesnx) - [FIX] Stop reading buffer bytes after the input when a stream error is built (#74) (@davesnx)
- [FIX] Keep the error inside the excerpt of a long line with invalid UTF-8 (#73) (@davesnx)
- [FIX] Read through the read buffer in
match_regexon a stream (#72) (@davesnx) - [FIX] Print line and column in
render_errorwhen a stream error starts in dropped input (#69) (@davesnx) - [FIX] Keep the bytes of a regex read-ahead when a read raises (#67) (@davesnx)
- [FIX] Keep line and column in stream errors after the line start is dropped (#47) (@davesnx)
- [FIX] Skip a prefix operator that commits and consumes no input (#41) (@davesnx)
- [FIX] Stop
expressionwhen aninfix_rightoperator and operand consume no input (#40) (@davesnx) - [FIX] Read more input in streaming
match_regexinstead of returning a cut match (#38) (@davesnx) - [FIX] Stop
fold_rightwhen the operator and element consume no input (#37) (@davesnx) - [FIX] Check the range of a span in
Slice.to_string(#34) (@davesnx) - [FIX] Count terminal cells for
render_errorcarets (#21) (@davesnx) - [PERF] Rescan only the frames that changed when a stream refills, so streaming a long
infix_rightchain no longer takes quadratic time (#136) (@davesnx) - [PERF] Cut the cost of a streaming parse that ends in the first chunk (#105) (@davesnx)
- [PERF] Defer the line index when a read drops ASCII input (#96) (@davesnx)
- [PERF] Cut the cost of each read in a stream: a 462-byte head in 2 chunks runs 20,591 instructions, down from 24,281 (#92) (@davesnx)
- [PERF] Keep a short streaming input on the minor heap (#66) (@davesnx)
- [PERF] Make
precedencecheaper: reuse the lookup frame and skip the restore when the lookup changed nothing (#65) (@davesnx) - [PERF] Take chunks straight into the input, without a read buffer (#64) (@davesnx)
- [PERF] Record one undo entry per
Refcell and frame instead of one per set (#46) (@davesnx) - [PERF] Read into spare room, so a stream does not copy all kept input on each read: 8 MB kept in 4 KB reads takes 0.016 s, down from 1.3 s (#45) (@davesnx)
- [PERF] Inline six primitives at call sites, and require odoc 3.2.1 for the docs (#44) (@davesnx)
- [PERF] Reduce the cost of the generic combinators (#35) (@davesnx)
- [DOCS] Document the
takewindow limit, and that a failure at end of input loses recovered values (#132) (@davesnx) - [DOCS] Document the zero-width prefix rule and fuzz committing prefix tokens (#125) (@davesnx)
- [DOCS] Render og:images in a static endpoint of the website, so the docs base needs no HTML rewrite (#123) (@davesnx)
- [DOCS] Generate the API pages through
fix-odoc-md.shinstead of a copiedsedin each dune rule (#122) (@davesnx) - [DOCS] Resolve odoc page links and same-site URLs per docs version (#115) (@davesnx)
- [DOCS] Tighten and sync the documentation across
parseff.mli, the API pages, the guides and the website (#114) (@davesnx) - [DOCS] Document when to use
commitand when to usecut(#109) (@davesnx) - [DOCS] Say that
expressionandprecedencehave their own loops, and when to use each (#108) (@davesnx) - [DOCS] Document
cutandcommit,listedge cases, recovering expressions and a failingsyncin the recovery guide (#101) (@davesnx) - [DOCS] Port the HTTP rules of ache into the example (#93) (@davesnx)
- [DOCS] Add the migration guide from 0.5 (#90) (@davesnx)
- [DOCS] Say that a domain runs one parse at a time, and that system threads on one domain are not supported (#78) (@davesnx)
- [DOCS] Correct the docs for the functions added since 0.5.0 (#75) (@davesnx)
- [DOCS] Document the cost of
peek_withandskip_toagainst a token kept by hand (#71) (@davesnx) - [DOCS] Add a Lua 5.4 parser example with error recovery (#43) (@davesnx)
- [DOCS] Fix website code spans that contain a backtick (#36) (@davesnx)
- [DOCS] Add the error recovery guide (#25) (@davesnx)
- [DOCS] Remove the remaining effects claims from docs, tests and examples (#20) (@davesnx)
- [CHORE] Reject malformed input in the fused arithmetic bench, explain the cross-domain state cache, and drop dead
fix-odoc-md.shrules (#120) (@davesnx) - [CHORE] Remove code comments: tautologies, stale notes and workaround excuses (#119) (@davesnx)
- [CHORE] Remove the broken hooks step from
make init, and correct the opam description and dependency groups (#77) (@davesnx) - [CHORE] Test the
peek_withrule in a token loop and after a failure that consumed input (#68) (@davesnx) - [CHORE] Test allocation of failed parses and
render_error(#23) (@davesnx) - [CHORE] Test allocation of the failures that stop repetitions (#22) (@davesnx)
- [CHORE] Bump dune-release-action to v0.6.0 (#19) (@davesnx)
0.5.0
- Breaking: errors are structured values.
parseandparse_sourcereturnError ewhereeis aParseff.error:{ kind; range; location; contexts; notes; excerpt }, wherelocationis the line and column in bytes.locationisNonewhen the line is not known (streaming, older than the buffered input).kind : error_kindisExpected { items; found; more },Failure,Custom,Depth_limit_exceededorBacktrack_window_exceeded, so a match on it is exhaustive.foundisText,End,ShortorValue. The result type is('a, error) Stdlib.result, andParseff.OkandParseff.Errorare nowStdlib.OkandStdlib.Error. The typeerrorand its parts areprivate: you can read and match them, not build them.noteandrangestay buildable, forfail ~notes. See Migrating. - Breaking:
errortakes an extensible variant.errorwas'e -> 'aand the result carried a free'e, so a parser could raise anintand the caller could read astring: a segfault.custom_erroris now an extensible variant,error : ?from:int -> ?notes:note list -> custom_error -> 'a, anderror_kindhasCustom of custom_error.render_error ?customanderror_message ?customtake a printercustom_error -> string. Declare your cases withtype Parseff.custom_error += Too_large of intand matchCustom (Too_large n). ACustommatch needs a final_case. - Breaking: diagnostics are typed by a collector.
warn : 'd -> unithad the same hole.Diagnostics.create ()makes a'd Diagnostics.t;warn d xandwarn_at d ~pos xrecord into it; pass it to the runner with~diagnostics:dand readDiagnostics.to_list dafter the parse, onOkand onError. The runner empties the collector first.warninto a collector the runner did not get does nothing. Diagnostics are still rolled back with a branch that backtracks. A collector in use by one parse raisesInvalid_argumentif another parse gets it, or ifDiagnostics.clearis called on it. - Breaking: two runners.
parseandparse_sourcetake?consume:[ `All | `Partial ](default`All) and?diagnostics. By default the parse fails withExpected End_of_inputwhen input remains.parse_until_end s pis nowparse s p, andparse_source_until_endis nowparse_source. To parse a leading part and ignore the rest, which was whatparse s pdid in 0.4, pass~consume:`Partial. Removed:parse_until_end,parse_source_until_end, theresultalias (it shadowedStdlib.resultunderopen Parseff),diagnostic,error_with_diagnosticsandresult_with_diagnostics. - Add
render_erroranderror_message.render_error ?name ?source ?custom eprints aname:line:col: [error] messageheader, the source line with carets under the failure, a╭─╯and╰──^bar that joins the opening token to the caret for the construct that started on an earlier line,* while parsinglines for the opencontexts, and notes. Control bytes, invalid UTF-8 and C1 controls are escaped in the excerpt as in the message, tabs keep the carets aligned, long lines are cut to 240 bytes around the failure, and the columns of the header and of the* while parsinglines count Unicode characters, whilelocation.colcounts bytes. When streaming has dropped the start of the line and~sourceis not given, the header isname: byte N: [error] ...and the context line saysfrom byte N. Source.of_function,of_chunksandof_seqstart with a smaller read buffer and grow it. The firstreadcall gets alenof 2040 instead of 4096; the buffer grows to 4096 after a read that fills it.- Failures at the end of the input keep what was expected.
[1, 2reportsexpected ',' or ']', found end of inputinstead of the old end-of-input error without items, including throughexpectandone_of_labeled. - A successful
look_aheadforgets the failures of its probe.look_ahead (many (char 'a')); char 'b'onaacreportsexpected 'b'at offset 0 instead of the probe’sexpected 'a'at offset 2. A failinglook_aheadis a failure like any other and merges with the earlier ones. commitforgets earlier failures only if it sealed a frame, andexpectkeeps relabeling correctly when acommitran inside it.- Expected items past 64 are counted. An error that expected more than 64 alternatives at one position keeps 64 distinct ones and counts the rest in
Expected.more; duplicates are removed first, so they never hide an alternative.expectandone_of_labeledstay correct when the set overflows. - A truncated read says how much is left.
take 5onabcreportsexpected 5 bytes, found only 3 (end of input), andfound end of inputwhen nothing is left.foundisShort 3orEndfor it. - Fix the error report of a streaming window overflow and of
~fromor notes that point before the buffer. The first raisedInvalid_argument "String.sub"when the window was exceeded on a long line.~fromolder than the buffered input keeps its position, andrender_errorprintsbyte Ninstead of a line it cannot know. - Fix the excerpt: a line cut at 240 bytes always ends with
..., a lone carriage return at the end of the input is not shown, and C1 control characters are escaped in messages. - Breaking: removed API. Each removed item has a replacement:
- The type
backtrack_window_erroris removed.Backtrack_window_exceededis an inline record{ limit; oldest }, so patternsBacktrack_window_exceeded { limit; _ }replaceBacktrack_window_exceeded info. catchis removed. It caught onlyfail, neverExpected, and dropped~fromand~notes. Check the condition before callingfail, or useoptionalandor_on parsers whose failure is anExpected.Utf8.digitis removed. Usedigit, which parses the same ASCII digits.BE.any_uint8,BE.any_int8,LE.any_uint8andLE.any_int8becomeany_uint8andany_int8at the top level.
- The type
Backtrack_window_exceededreports the parser position. Its error position, line and excerpt are those of the parser when the window was exceeded, not the end of the read that did not fit, and the open* while parsinglines follow the usual rule.- Polish the error output.
- A streaming error whose line is not known, such as a
~fromolder than the buffered input, printsinput: byte N: [error] ...with no excerpt instead of a line and column computed from the partial buffer.render_erroralso indents the*rows by two spaces then. - A mismatch of
BE.int16,BE.int32,BE.int64and theLEversions reportsexpected int16be 0x0001, found 0x0002: the endianness is in the label andfoundis the integer read in the same width.foundisValuefor it. 'in a quoted character is escaped as'\'', a non-UTF-8 byte fromchar '\xE9'prints as'\xE9', and a truncatedfoundis'abcdef'....- Non-breaking spaces, format characters, line and paragraph separators, and a combining mark at the start of the quoted text are escaped as
\u{...}infoundand in expected items. - A
Customerror without a~customprinter sayscustom error (no ~custom printer given). - A message lists at most 8 expected items and then
, or N more alternatives(or 1 more alternativefor one).Expected.moreholds the count of alternatives past the 64 kept. - The excerpt shows control bytes, invalid UTF-8 and C1 controls as the escapes of the message, and the carets and the corner bar count the escape.
- The rows the renderer adds never end with a space, including empty source rows and an empty message. Source text is printed byte for byte, so a source line with trailing spaces keeps them.
Depth_limit_exceededandBacktrack_window_exceededkeep the* while parsinglines that were open and end with* help: raise ~max_depthor* help: call commit or cut earlier, or raise ~backtrack_window.* ... and 1 moreprints the frame instead, and the...row for hidden lines is aligned with the gutter.- The label of a regex without
~labelistext matching the pattern, andone_of []expects nothing: alone it fails withFailure "no alternative matched", and next to other failures at the same position it adds nothing to them.
- A streaming error whose line is not known, such as a
- Add
?labeltomatch_regex. A failed match reportsexpected <label>and merges with the other alternatives expected at the same position. Without~labela failed match expectstext matching the pattern. - Add
?fromand?notestofailanderror.~frommakes the error cover the bytes fromfromto the current position, and~notesattaches annotations: a note with a range is underlined in the error excerpt, a note without one is printed as a* note:line. Plain calls behave as before. The error of afailalso lists thecontexts it unwound through. - Add
context.context ?delimited name parserrunsparserinside a named construct. A failure inside it remembers the open constructs, outermost first, with their start offsets, for the error report. A parser that never callscontextpays nothing; a call costs about 100 instructions. - Add
cut.cut ()declares the running construct decided. It seals everyor_,one_of,many,sep_by,optionalandfold_*frame opened since the innermost enclosingcontext, and stops atlook_ahead. If thatcontextthen fails, the frames outside it are sealed too, somany (fun () -> context "statement" (fun () -> consume "let"; cut (); ...))reports the error of a broken statement instead of stopping the loop and ignoring the rest of the input.commit ()still seals the nearest frame only. - Report the furthest failure. A failed parse now returns the error at the highest position where any primitive failed, also inside branches that
or_,many,sep_by,optionalorfold_leftabandoned.[1, 2, 3,]reports the missing value at the], andsep_by (consume "ab") (char ',')followed byend_of_inputonab,ab,axreports thexat offset 7 instead of the trailing input at offset 5. Code that comparesposor the message of an error sees different values. - Merge, sort and deduplicate what was expected. Failures at the same position give one message:
expected "else", "if", or "while"instead ofexpected "if" or expected "else" or expected "while", andor_ digit digitsaysexpected digitonce. The order of the branches does not change the message. Characters print as'x', literals as"abc". consumefails at the first byte that differs.consume "ab"onaxfails at offset 1 withexpected "b", andconsume "hello"onhelfails at offset 3 withexpected "lo", found end of input. Both used to report offset 0. When fewer bytes remain than the literal needs but the available bytes already differ,consumefails at the first differing byte, soor_composes the messages of its branches. Only input that ends inside a prefix of the literal hasfoundset toEnd. A mismatch inside a multi-byte character is reported at the start of the character:consume "é"onèfails at the character, expecting"é".expectandone_of_labeledrelabel only failures at their start. A parser that got past its first byte keeps its own, more precise message.expect "key" (fun () -> consume "id:"; digit ())onid:xreportsexpected digitat offset 3.expectandtake_while ~labelmessages now start withexpected, andone_of_labeledreportsexpected number or stringinstead ofexpected one of: number, string.- Report a custom error from an abandoned branch when it is the furthest failure.
errorstill letsor_,manyandoptionalbacktrack. At the same position a custom error wins overExpected, and the first of two custom errors wins. It used to be the second. commitforgets the failures at or beyond its position. A committed branch reports only what it expected itself, not the failure of the previous branch.take_while ~at_leastwithout~labelsaysexpected at least n charactersinstead oftake_while.Utf8.charno longer formats a label on every call. Its failure reports the expected character, formatted only when an error is built.- Reduce the cost of failures. Primitives record the furthest failure in the parse state instead of allocating an exception that carries a message,
or_reuses its rewind frame for the right branch, and a finished parse allocates one closure less. - Improve runtime performance. Combinators read the parse state without a
Domain.DLSlookup, backtracking frames no longer allocate, internal failures skip backtrace recording, and streaming compaction no longer rebuilds line starts. - Fix
BE.int16andLE.int16for values above0x7FFF. They compared the signed result ofany_int16, soBE.int16 0xFFFEnever matched"\xFF\xFE". They now compare the 16 bits, accept-32768to65535and raiseInvalid_argumentoutside that range.int16,int32andint64mismatches are now reported at the start of the field instead of after it. - Fix concurrent parses on one domain. Two
parse_sourcecalls whosereadsuspends, for example in two Eio fibers, corrupted each other’s state and raisedInvalid_argument "Parseff.State.pop_rewind_frame". Parseff now installs the parse state again after everyread, and a finished parse no longer leaves its state behind. Onlyreadmay suspend; a suspension inside a parser callback is still not supported. - Fix streaming memory growing with the input. Compaction kept one line index entry per newline for the whole stream. The index now keeps only the retained buffer and a count of dropped lines, so
locationstays correct and memory is bounded by the window. - Fix
match_regexhiding a full backtrack window. When the window was full and the source had not ended, the regex ran on the short buffer and failed, soor_took another branch. It now returns a match that ends before the buffered end, and otherwise fails with`Backtrack_window_exceeded, astakedoes, because more input could change the result. - Check streaming arguments.
parse_sourceraisesInvalid_argumentfor~backtrack_windowbelow2,Source.of_channelfor~buf_sizebelow1, and a parse for areadresult outside0..len. A window of0or1used to report a false end of input. - Fix streaming documentation.
spanis an owned copy in streaming,match_regexreads ahead half a window instead of retrying at chunk boundaries, and a source is for one parse. - Fix
expectandone_of_labeledrelabeling custom errors. A custom error raised through anor_orone_ofwith several branches was replaced by theexpectorone_of_labeledmessage. It now passes through unchanged, as documented. - Fix
many,sep_by,end_byandfold_leftlooping forever on parsers that consume no input. The loop now stops after an iteration that consumes nothing and drops that iteration’s result and diagnostics.~at_leaststill applies to the kept results. - Fix
take nraisingInvalid_argumentfor a very largen. The length check overflowed.takenow fails with anExpectederror whosefoundisShortorEnd. A negative count also fails withExpected,expected non-negative length, found -1, as in 0.4, soor_recovers from it. - Document the cost of
match_regexfailures.Researches forward when the regex does not match at the current position, so a failed match scans the rest of the input and a loop of failing matches takes quadratic time.
0.4.0
- Breaking: streaming now uses a bounded sliding buffer.
parse_sourceandparse_source_until_endaccept~backtrack_window(default65536) and fail with`Backtrack_window_exceeded of backtrack_window_errorwhen 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_windowif 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 stringinstead of`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
`Expectedinstead of`Failure.BE.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 a badly organized 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