Changelog
v1.1.0 - 2026-11-03
Added
chars.newline, which parses\nand\r\n.chars.number, which parses integers and floats like1,1.5and1e5as aFloat.chars.recognize, which returns the consumed text as aString.
v1.0.1 - 2026-11-03
Fixed
chars.naturalandchars.integerreturn an error instead of crashing on Erlang for integers with over a million digits.chars.string_literalrejects a quote or backslash followed by a combining mark, and an unterminated string fails withexpected closing quote.chars.letter,chars.alphanumericandchars.hex_digitonly match single characters.one_ofbuilds its expected list once instead of on every failure.
v1.0.0 - 2026-10-29
Breaking changes
gleam_stdlib1.x is now required.Parseris now an opaque type instead of a function.ParseResultis removed;parseandparse_stringreturnResult(Parsed(i, a), ParseError(i)).Inputis now opaque. Useinput.tokens,input.positionandinput.at_end;get,get_n,nextandnext_nare removed.Parsed.inputis renamed toParsed.remaining.ParseErrorvariants hold the errorpositioninstead of the remaining input, and there is a newCustomvariant for custom error messages.- Renamed combinators:
alt→orjust→tokento→replaceleft→then_skipright→skip_thenmaybe→optionallabelled→label
satisfyingtakes afn(i) -> Bool; thePredicatetype is removed.do_choiceandpears.okare no longer public.chars.numberis renamed tochars.natural.chars.charis removed, usecombinators.token.chars.inputis removed, usepears.parse_string.
Added
pears.parse_allandpears.parse_string_all, which fail if any input is left over.pears.format_error,pears.error_message,chars.format_errorandchars.line_columnfor turning errors into messages.succeed,fail,then(works well withuse) andtry_map.chain_leftandchain_rightfor operator expressions.peek,not_followed_byandhidden.exactly,at_least,at_most,many_till,sep_end_by0andsep_end_by1.with_spanand theSpantype.chars.letter,chars.alphanumeric,chars.hex_digit,chars.integer,chars.float,chars.string_literal,chars.case_insensitive,chars.lexemeandchars.line_comment.
Changed
- Errors report the failure that got furthest into the input, and alternatives
that fail at the same position have their expected tokens merged. Errors from
many0,optional,sep_by0and similar combinators are kept, so the final error says what else could have come next. chars.stringerrors point at the first character that doesn’t match.labelonly relabels errors at the position where its parser started.
Fixed
- Reading the next token is O(1) instead of O(n).
many0no longer overflows the stack on JavaScript for long inputs and no longer loops forever on parsers that succeed without consuming input.