Releases: pointfreeco/swift-parsing
0.13.0
0.12.1
What's Changed
- Fixed:
Formatted
parser now only consumes what it matches, and not the rest of the string (#301). - Infrastructure: Fix seconds mapping in Date benchmark (thanks @jacoblapworth, #295).
New Contributors
- @jacoblapworth made their first contribution in #295
Full Changelog: 0.12.0...0.12.1
0.12.0
What's Changed
Warning: This release contains breaking changes in order to support Swift 5.8's rewritten result builder implementation. While the package will build for Swift 5.7, we recommend delaying this upgrade till you can use Swift 5.8, as the changes impact compile time performance of
ParserBuilder
andOneOfBuilder
.
-
Added: Swift 5.8 Support (thanks @JaapWijnen, #289). Note: due to result builder changes in Swift 5.8, code that compiled just fine in Swift 5.7 and Parsing 0.11.0 and earlier may be source incompatible in Swift 5.8 and this Parsing release.
See this discussion for more details.
-
Added: Parsers can now be implemented in the SwiftUI "body" style:
struct UserParser: Parser { var body: some Parser<Substring, User> { Parse(User.init(id:name:isAdmin:)) { Int.parser() "," Prefix { $0 != "," } "," Bool.parser() } } }
-
Added: A new
Backtrack
parser (#287). Useful for adding explicit backtracking to a parser. -
Changed: The
CaseIterableRawRepresentable
parser printer has been extended to work with anyFixedWidthInteger
(thanks @ytyubox, #277).
New Contributors
Full Changelog: 0.11.0...0.12.0
0.11.0
What's Changed
- Swift 5.7 Updates (#261)
- Changed: Parsing's builder limitations have been greatly improved.
OneOfBuilder
now takes an unlimited number of parsers, andParserBuilder
now takes an unlimited number ofVoid
parsers, and up to 10 non-Void
parsers. - Changed: Swift 5.7 Improvement: The
Parser
,ParserPrinter
,Conversion
, andPrependableCollection
protocols now have primary associated types. - Added:
Formatted
parser-printer, for incrementally parsing and printing using Apple's family of formatters.
- Changed: Parsing's builder limitations have been greatly improved.
- Changed: The
End
parser's conditional conformance requiringCollection
has been broadened to work with anySequence
(thanks @JaapWijnen, #250). - Fixed: The
Prefix
parser-printer could erroneously fail to print whenmax
was configured. This has been fixed (thanks @oskarek, #256). - Removed: The experimental
_URLRouting
module has been removed. Please upgrade to the official package, instead. - Infrastructure: Typo fixes (thanks @kamcma, #253; @elfenlaid, #257, #258).
New Contributors
- @kamcma made their first contribution in #253
- @elfenlaid made their first contribution in #257
Full Changelog: 0.10.0...0.11.0
0.10.0
- Added:
StartsWith
,PrefixThrough
, andPrefixUpTo
overloads to aid in type inference for substring and UTF-8 parsers (thanks @tgrapperon). - Changed: Parsing now has Apple platform requirements equivalent to SwiftUI (iOS 13+, macOS 10.15+, tvOS 13+, watchOS 6+). If these minimum requirements don't fit your needs, let us know.
- Fixed:
PipeEnd
now conforms toParserPrinter
, fixing printability of piped parsers (thanks @JaapWijnen). - Deprecated: the
_URLRouting
module is now deprecated. Use the URL Routing package instead. - Removed:
Conversions.Parsing
, which was not reachable through any static member onConversion
, and confused some users. If you have a use case motivating this conversion, let us know.
0.9.2
- Fixed: Added a missing
ParserPrinter
conformance toOptionalOneOf
, which prevented parsers that usedif
statements in@OneOfBuilder
blocks from being printers.
The following changes have been made to the more experimental _URLRouting
module:
- Added: A
Body()
initializer that takes no arguments. It simply parses the entire body asData
. - Infrastructure: documentation changes.
0.9.1
- Fixed: A
Double.parser()
overflow bug has been fixed (thanks @tgrapperon).
The following changes have been made to the more experimental _URLRouting
module:
- Added: A
URLRoutingClient
for wrapping a router and URL session into an HTTP client. - Fixed: A few potential bugs around
Field
andBody
being empty.
0.9.0
0.8.0
-
Added: A case-iterable, raw-representable parser. Simply tack
.parser()
onto any conforming type:enum Role: String, CaseIterable { case admin case guest case member } try Role.parser().parse("admin") // Role.admin
-
Fixed: An Xcode 13.3 compiler error has been fixed.
-
Fixed:
Optionally
will now backtrack if the parser fails (thanks @randomeizer). -
Fixed:
Double.parser()
now parses as freely asDouble.init
'sLosslessStringConvertible
functionality. -
Optimized:
Peek
andNot
will only backtrack when they are successful (i.e., ifPeek
's upstream parser successfully parses a value, or ifNot
's upstream parser fails to parse a value). Backtracking on failure is now delegated to any upstreamOneOf
s. -
Optimized:
OneOfMany
no longer backtracks its final failure, bringing it in line with the behavior of the variadicOneOf
s. -
Breaking change: The non-
inout
overloads ofParser.parse
now attempt to fully consumeCollection
-based inputs.// Before: try Int.parser().parse("42hello") // 42 // After: try Int.parser().parse("42hello") // error: unexpected input // --> input:1:13 // 1 | 42hello // | ^ expected end of input
This change makes parsing a bit more strict by default in order to catch potential issues with input.
If you want to ignore trailing output, use the
inout
version ofparse
, or explicitly describe how the input should be ignored in the parser, for example usingOptionally { Rest() }.map { _ in () }
. -
Breaking change: The
Rest
parser now fails when the rest of input is empty.// Before: try Rest().parse("") // "" // After: try Rest().parse("") /// error: unexpected input /// --> input:1:1 /// 1 | /// | ^ expected a non-empty input
If your use of
Rest
should not fail on empty input, wrap it explicitly in anOptionally
parser, or usereplaceError(with:)
to provide a default value of""
. -
Breaking change:
Peek
is now aVoid
parser. It can be used to inspect a value in order to test that a parser should be successful, but capturing any data is now the responsible for the parsers that comes afterward (thanks @randomeizer). -
Breaking change: The
isSigned
parameter ofInt.parser()
has been removed.Int.parser()
will now always parse a sign ifFixedWidthInteger.isSigned
returns true (e.g.,Int.parser()
will parse a sign,UInt.parser()
will not.).If you want to parse a number without a sign, use a more explicit parser, or test for the sign before using
Int.parser()
. E.g.:let digits = Prefix { $0.isNumber }.compactMap(Int.init) // ...or... let digits = Parse { Not { OneOf { "-"; "+" } } Int.parser() }
-
Updated:
Double.parser()
can now be used on any type that conforms toBinaryFloatingPoint
, includingFloat16
. -
Updated:
Many
'supdateAccumulatingResult
can now throw. -
Updated: Documentation has been revamped, including a new DocC-based static site with articles that cover common topics.
-
Infrastructure: Documentation fixes (thanks @haikusw).
0.7.1
- Improved: Error messages that occur at the same input range are now coalesced into a single error (thanks @mayoff).
- Fixed:
Prefix
now eagerly consumes input. - Fixed:
Prefix
with a minimum length now throws an error at the correct input location, rather than the input location of that minimum length. - Infrastructure: README and documentation updates.