Parsing with Perl 6 Regexes and Grammars
This book is 65% complete
Last updated on 2017-11-28
About the Book
As humans, we are incredibly good at finding patterns. So we assume that as programmers, we must be good at using patterns to parse text. But it's a skill that needs to be learned. This book aims to teach you how to write good regexes and parsers with Perl 6.
It starts from the very basics of regular expressions, and then explores how they integrate with regular Perl 6 code. The result of a successful regex match is a Match object, which contains all the useful information for extracting data, so that is the next topic.
Then we discuss how regexes work under the hood, and how Perl 6 uses a mixture of finite state machines and backtracking to do its magic. With this understanding, we can explore common techniques for constructing regexes and exploring the data under scrutiny.
So far, the regexes can only match relatively simple formats. But with reusable named regexes and grammars, the sky is the limit. Figuratively, of course. We discuss techniques for code reuse in grammars, and how to write parser for more involved data formats.
One of my favorite topics is the generation of good error messages for when the input can't be parsed by a grammar, so there will be a separate chapter on that.
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...