Skip to content

Releases: pointfreeco/swift-parsing

0.13.0

30 Jul 22:36
a0e7d73
Compare
Choose a tag to compare

What's Changed

  • Changed: Bump to Case Paths 1.0 (#306).
  • Fixed: Remove unused package dependencies (#303).
  • Fixed: Remove a Swift 5.9 warning (#304).
  • Infrastructure: Improve Date parser demo (#305).

Full Changelog: 0.12.1...0.13.0

0.12.1

26 May 16:33
27c941b
Compare
Choose a tag to compare

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

Full Changelog: 0.12.0...0.12.1

0.12.0

31 Mar 15:54
c6e2241
Compare
Choose a tag to compare

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 and OneOfBuilder.

  • 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 any FixedWidthInteger (thanks @ytyubox, #277).

New Contributors

Full Changelog: 0.11.0...0.12.0

0.11.0

08 Dec 20:10
Compare
Choose a tag to compare

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, and ParserBuilder now takes an unlimited number of Void parsers, and up to 10 non-Void parsers.
    • Changed: Swift 5.7 Improvement: The Parser, ParserPrinter, Conversion, and PrependableCollection protocols now have primary associated types.
    • Added: Formatted parser-printer, for incrementally parsing and printing using Apple's family of formatters.
  • Changed: The End parser's conditional conformance requiring Collection has been broadened to work with any Sequence (thanks @JaapWijnen, #250).
  • Fixed: The Prefix parser-printer could erroneously fail to print when max 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

Full Changelog: 0.10.0...0.11.0

0.10.0

28 Jun 22:30
bc92e84
Compare
Choose a tag to compare
  • Added: StartsWith, PrefixThrough, and PrefixUpTo 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 to ParserPrinter, 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 on Conversion, and confused some users. If you have a use case motivating this conversion, let us know.

0.9.2

26 Apr 16:37
28d32e9
Compare
Choose a tag to compare
  • Fixed: Added a missing ParserPrinter conformance to OptionalOneOf, which prevented parsers that used if 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 as Data.
  • Infrastructure: documentation changes.

0.9.1

20 Apr 22:57
Compare
Choose a tag to compare
  • 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 and Body being empty.

0.9.0

11 Apr 05:38
edb72e8
Compare
Choose a tag to compare

Introduced the ParserPrinter protocol for invertible parsing.

0.8.0

10 Mar 18:53
Compare
Choose a tag to compare
  • 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 as Double.init's LosslessStringConvertible functionality.

  • Optimized: Peek and Not will only backtrack when they are successful (i.e., if Peek's upstream parser successfully parses a value, or if Not's upstream parser fails to parse a value). Backtracking on failure is now delegated to any upstream OneOfs.

  • Optimized: OneOfMany no longer backtracks its final failure, bringing it in line with the behavior of the variadic OneOfs.

  • Breaking change: The non-inout overloads of Parser.parse now attempt to fully consume Collection-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 of parse, or explicitly describe how the input should be ignored in the parser, for example using Optionally { 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 an Optionally parser, or use replaceError(with:) to provide a default value of "".

  • Breaking change: Peek is now a Void 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 of Int.parser() has been removed. Int.parser() will now always parse a sign if FixedWidthInteger.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 to BinaryFloatingPoint, including Float16.

  • Updated: Many's updateAccumulatingResult 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

17 Feb 21:23
Compare
Choose a tag to compare
  • 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.