The simplest way to describe Lex is that it runs user-supplied C code blocks for regular expression matches. However, a nice lexing tool like Lex can be useful on its own, even when not paired with a parser. The second, parsing, groups the scanned chunks following potentially recursive rules. The first stage, lexing (aka scanning), breaks the input into meaningful chunks of characters. People usually use two stages to process structured text. And, I promise, none of the typical calculator examples. I’ll motivate each feature of the parser generator with a concrete problem it can solve. We’ll see how to properly integrate parser generators into your build system, how to create thread-safe parsing modules, and how to parse real data formats. We’ll also cover their later incarnations as Flex and Bison.Ībove all, this guide is practical. ![]() We’ll cover Lex and Yacc in this guide because they are mature and portable. ![]() ![]() Reading file formats, talking over the network, creating shells, and analyzing source code are all easier using a robust parser.īy taking time to learn general-purpose parsing tools, you can go beyond fragile homemade solutions, and inflexible third-party libraries. Although parsing is often described from the perspective of writing a compiler, there are many common smaller tasks where it’s useful.
0 Comments
Leave a Reply. |