talira

swift-parsing

Composable, fast, invertible parsers for Swift from Point-Free

open sourceMITfree

swift-parsing is a Swift library for turning unstructured data into structured data by combining small parsers into larger ones. Its parsers can work on any input and output, including UTF-8 code units for speed, and can be inverted into printers that turn structured data back into text, which its makers use for serialization and URL routing. It was designed over a series of Point-Free episodes.

Problems it solves

  • parse a custom text format in Swift without writing a hand-rolled scanner
  • turn lines of a log file into Swift structs
  • write one definition that both parses and prints a format in Swift

Features

  • compose small parsers into larger ones
  • parse any kind of input into any kind of output, including UTF-8 code units
  • invertible parsers that also print structured data back out
  • aims for the performance of hand-written parsers