We’ve seen the various parts of StringScanner in action, but to get an appreciation for how they work in concert it would be useful to see a slightly broader example.
One situation where you might write a parser is when encountering a new file format, one for which there isn’t a ready-made library that can be used to parse its content. As an example, let’s take the following fictional file format, which in this case stores the configuration of a website:
name = "Alice’s website"
description = "Alice's personal blog"
url = "http://alice.example.com/"
public = "true"
version = "24"
It’s pretty simple, as file formats go. The name of each configuration variable is at the start of the line; there’s ...