Introduction
There's not a better way to learn how to use a package — or even just to learn what a package is really good for — than to actually use that package. To that end, this is a tutorial in which we use Kessel to create a parser that actually does something useful.
So what should we parse? For the purpose of this tutorial, I was looking for a couple things. First, it had to be the right amount of complexity. There's an example of a CSV parser earlier in the documentation that's five lines long, which wouldn't make for much of a tutorial at all. On the other hand, one could write an entire book on parsing and compiling C (and in fact many such books have been written), and that's a bit much for a tutorial.
The second requirement was that there be a clearly defined spec. I want the focus to be on how to write parsers, not on trying to decipher the language before being able to even figure out what parsers to write.
With that in mind, I chose to base the tutorial on writing a TOML parser. TOML is a language for writing configuration files, much like JSON or YAML or even XML could be. It has more features than JSON, has a nicer and more consistent syntax than YAML, and...well, anything's better than XML. The fact that it's my favorite configuration language probably played a part in me picking it as well.
The application developed in this tutorial will take a TOML file and spit out an equivalent JavaScript object.
We'll have to get deep into the details when the writing actually starts, but to start, let's just get a quick look at TOML syntax.
A 10,000 foot view of TOML
We'll equate TOML structures to JavaScript structures, since after all we'll be turning the former into the latter.
The first structure that we'll mention, briefly, is the file itself. Our parser is always going to output a single