Releases: drhagen/parsita
Release list
Parsita 2.3.0
This release adds one feature, the seq parser as syntactic salt for the _ & _ syntax. The & syntax always relied on magic to do its work and was not completely bulletproof. This provides an alternative for the rare situations that the & syntax is too problematic.
Parsita 2.2.4
This release only added a license file to the sdist so that the package is publishable on conda-forge.
Parsita 2.2.3
Parsita 2.2.2
This release mainly tweaks the supported versions of dependencies, but also includes one fix for typing.
- Handle type annotations when applied to forward declarations
- Drop support for Python 3.9
- Add support for Return 0.24 and 0.25
Parsita 2.2.1
The only publicly visibly changes in this release improve support for mypy by re-exporting all public members using the X as X syntax.
Parsita 2.2.0
- Added support for Python 3.13 (#109)
- Dropped support for Python 3.8 (#109)
- Refactored to use some >=3.9 features (#111)
- Added
py.pytedand runmypyon the source in CI (#115)- This was best effort as Python's type system lacks the features needed to describe a parser combinator system
- Fixed the
reprof some parsers (#114)
Parsita 2.1.1
This is a maintenance release to document compatibility with recent versions of dependencies. There is no change to the code of Parsita.
- Added support for Python 3.12
- Known issue: Poetry does not yet add the classifier for Python 3.12, but resolvers don't use this, so it doesn't really matter.
- Added support for Returns 0.21 and 0.22
Parsita 2.1.0
This is a quick follow-on to the 2.0.0 release. I neglected to make some methods private that were supposed to be private. Because the 2.0.0 release was only three days ago, I hope this will be fine. This is just a bugfix release for anyone who combines the built-in parsers to make their parsers (most users). But this is a severely breaking change for any custom parsers (inherit from Parser rather than use them).
- Made
Parser.consumeprivate- Renamed
consumeto_consume - Renamed
cached_consumetoconsume - This is the breaking change for custom parsers. Custom parsers now need to override
_consumeinstead ofconsumeand need to callconsumeinstead ofcached_consume. This actually brings the 2.x branch a little bit closer to the 1.x branch.
- Renamed
- Renamed
StringReader.current_lineto_current_line - Moved
Parser.handle_otherto a global function- Export this function as
parsita.parsers.wrap_literal - Use
wrap_literalfor all the parsers, not just the operators- Literal wrapping now applies to all non-
Parserobjects, not juststr prednow wraps literals like the other parsers, rather than requiring a properParserobject
- Literal wrapping now applies to all non-
- Export this function as
Parsita 2.0.0
This second major release doubles down on the ease-of-use promise of Parsita. The interface has been simplified and the amount of global mutable state needed to perform Parsita's magic has been drastically reduced. The internals have been totally rewritten to eliminate the possibility catastrophic backtracking, a rare and confusing property of some parsers.
Code that runs on 1.x will need to be modified to run on run on 2.x. The 1.8.0 release was made to ease the transition. Code written for 1.7.2 and earlier will produce deprecation warnings when run in 1.8.0. Code that has been modified to no longer produce those deprecation warnings should run without further modifications on 2.0.0.
- Replace
GeneralParsersandTextParserswithParserContext, which behaves like aTextParserswith a defaultwhitespaceofNone- The separate parser contexts were always kind of confusing and, in reality, not all that different. Both could parse text. The only advantage of
TextParserswas itswhitespaceoption. Add that toGeneralParsersandTextParsersis no longer needed andParserContextis born.
- The separate parser contexts were always kind of confusing and, in reality, not all that different. Both could parse text. The only advantage of
- Replace the custom
parsita.Resultwithreturns.result.ResultResult,Success, andFailureare now simple reexports of the classes fromreturns.resultResult.or_die()andSuccess.valuehave been replaced byResult.unwrap()Failure.messagehas been replaced bystr(Result.failure())
- Replace the internal parsing engine with a packrat parser
- Every time a parser finishes at a particular location in the input, a packrat parser caches the response. This guarantees that the time the parser takes to parse is linear in the input. It should no longer possible to write a parser that appears to hang on a small amount of input.
- This is only a breaking change for custom parser classes (i.e. those that inherit from
Parserinstead of being built from combinations of other parsers). Classes that inherit fromParsersneed to adopt the following changes:consumeis now an abstract protected method.consumemust be implemented in concrete subclasses ofParser, but is invoked bycached_consumedonly and should not be directly invoked by other parsers.- Invoke
cached_consumeon inner parsers instead ofconsumedirectly - Return
Noneon failure instead ofBacktrack - No need to do
status.mergeanymore
- Raise custom
RecursionErrorinstead of using the builtin one when Parsita detects infinite recursion- It has
parserandcontextattributes to store useful state about the parsing at the failure
- It has
ParseErrornow has attributes (farthestandexpected) so that the state can be queried instead of lost in the string- Remove
parsita.options.parse_methodglobal mutable stateParser.parseis now a normal method instead of being extracted from global mutable state at parser instantiation
- Remove
parsita.options.handle_literalglobal mutable stateLiteralParsernow handles everything. It has a specialization forStringReaderfor performance.
- Drop support for Python 3.7
Parsita 1.8.0
This is likely to be the last minor release in the 1.x series. It is mainly intended to ease the transition to version 2. Bug fixes will continue to be made to the 1.8.x series, but new features will be added only to the 2.x series unless backporting is not particularly painful.
- Create
ParserContextas a new context that behaves likeTextParsers, but has a defaultwhitespaceofNone.TextParsersandGeneralParsersare now deprecated in favor ofParserContext, which will be the only context starting in 2.0.0.
- Parsita
Resultnow inherits fromreturns.Result.- The inheritance purely implements the Parsita-specific methods (
Result.or_die,Success.valueFailure.message) and deprecates them to ease transition to 2.0.0, when Parsita will reexport the classes from Returns unmodified.
- The inheritance purely implements the Parsita-specific methods (
- Failure now wraps the
ParseErrorexception rather than a string.Failure.messagestill gives a string.- This makes room for
ParseErrorkeeping useful information as attributes rather than the information being destroyed into a string.
- This makes room for
- Make
regwork in aGeneralParserscontext and on bytes (contributed by Chris Wheeler).- Add
.dropto theReaderbase class - Add efficient
.dropmethod to theSequenceReaderclass - Change
RegexParserto allow bytes
- Add
Code that runs in Parsita 1.x should run in 1.8.0, though with with deprecation warnings. Code that runs in 1.8.0 without deprecation warnings should run in Parsita 2.x. Note that this only applies to code that uses the Parsita parsers. If you wrote your own parser (i.e. you inherit from Parser), it's just going to have be fixed in 2.0; the internals of Parsita were changed to much to have custom parsers work in both versions.