Chapter 8. Parsers—Because BNF Is Not Just for Academics Anymore

We've covered a lot of ground so far, but most of the examples have been one or two lines of code. Sure, the control structures are helpful, and of course most of our programming projects pit dragons and bunnies in battle, but one of the biggest challenges we face is dealing with real-world data. If we're lucky, the real-world data will be well formed in XML. But sometimes we're not so lucky. Sometimes we're handed a spec for a wire format or a text file format and told to "deal with it." Good news: Scala is very good at helping you deal with it.

Scala comes with a parser combinator library that makes writing parsers simple. Furthermore, because your parser is written in Scala, there's ...

Get Beginning Scala now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.