🎉 Black Friday Sale! Save 30% when you subscribe today.

Parsing Xcode Logs: Part 1

Episode #121 • Oct 19, 2020 • Subscriber-Only

Now that we’ve refamiliarized ourselves with parsing, let’s parse something even more complex: XCTest logs. We will parse and pretty-print the output from xcodebuild and discover more reusable combinators along the way.

Previous episode
Parsing Xcode Logs: Part 1
Next episode
Locked

Unlock This Episode

Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.

Sign in with GitHub

Introduction

And so that’s our recap of parsers and parser combinators. We can already see the power in them, but as we said before, this is only the tip of the iceberg. There is so much left to explore, including generalization, performance, and invertibility. And we will get to all of that, but we want to do one more thing before ending the recap. So far we haven’t shown too much new stuff to those who were already caught up on our past episodes on parsing, so we’d like to show off something that everyone can get benefit from.

We will create a whole new complex parser from scratch, and it will push our current knowledge of parsers even further. We are going to write a parser that will process all of the logs that Swift spits out when running tests.

XCTest log output


References

  • Combinators
    Daniel Steinberg • Sep 14, 2018

    Daniel gives a wonderful overview of how the idea of “combinators” infiltrates many common programming tasks.

    Note

    Just as with OO, one of the keys to a functional style of programming is to write very small bits of functionality that can be combined to create powerful results. The glue that combines the small bits are called Combinators. In this talk we’ll motivate the topic with a look at Swift Sets before moving on to infinite sets, random number generators, parser combinators, and Peter Henderson’s Picture Language. Combinators allow you to provide APIs that are friendly to non-functional programmers.

  • Parser Combinators in Swift
    Yasuhiro Inami • May 2, 2016

    In the first ever try! Swift conference, Yasuhiro Inami gives a broad overview of parsers and parser combinators, and shows how they can accomplish very complex parsing.

    Note

    Parser combinators are one of the most awesome functional techniques for parsing strings into trees, like constructing JSON. In this talk from try! Swift, Yasuhiro Inami describes how they work by combining small parsers together to form more complex and practical ones.

  • Regex
    Alexander Grebenyuk • Aug 10, 2019

    This library for parsing regular expression strings into a Swift data type uses many of the ideas developed in our series of episodes on parsers. It’s a great example of how to break a very large, complex problem into many tiny parsers that glue back together.

  • Regexes vs Combinatorial Parsing
    Soroush Khanlou • Dec 3, 2019

    In this article, Soroush Khanlou applies parser combinators to a real world problem: parsing notation for a music app. He found that parser combinators improved on regular expressions not only in readability, but in performance!

  • Learning Parser Combinators With Rust
    Bodil Stokke • Apr 18, 2019

    A wonderful article that explains parser combinators from start to finish. The article assumes you are already familiar with Rust, but it is possible to look past the syntax and see that there are many shapes in the code that are similar to what we have covered in our episodes on parsers.

  • Sparse
    John Patrick Morgan • Jan 12, 2017

    A parser library built in Swift that uses many of the concepts we cover in our series of episodes on parsers.

    Note

    Sparse is a simple parser-combinator library written in Swift.

  • parsec
    Daan Leijen, Paolo Martini, Antoine Latter

    Parsec is one of the first and most widely used parsing libraries, built in Haskell. It’s built on many of the same ideas we have covered in our series of episodes on parsers, but using some of Haskell’s most powerful type-level features.

  • Parse, don’t validate
    Alexis King • Nov 5, 2019

    This article demonstrates that parsing can be a great alternative to validating. When validating you often check for certain requirements of your values, but don’t have any record of that check in your types. Whereas parsing allows you to upgrade the types to something more restrictive so that you cannot misuse the value later on.

  • Ledger Mac App: Parsing Techniques
    Chris Eidhof & Florian Kugler • Aug 26, 2016

    In this free episode of Swift talk, Chris and Florian discuss various techniques for parsing strings as a means to process a ledger file. It contains a good overview of various parsing techniques, including parser grammars.

Downloads

Get started with our free plan

Our free plan includes 1 subscriber-only episode of your choice, access to 64 free episodes with transcripts and code samples, and weekly updates from our newsletter.

View plans and pricing