Parsing complicated stuff with perl

Recursive Descent Parsers

Regular Expressions

other


The last day or two I've returned to giving myself a crash course in the Parse::RecDescent Perl module. An extremely powerful flexible amazing module, which uses a grammar definition to generate a recursive descent parser for you. Great for parsing anything. Not only to write your own compiler, but to write maintainable parsers for everything. Downside is that the learning curve is so steep that you nearly fall over backwards. Even though I've been using Perl for nearly five (or 4?) years, it really messed my brain to understand the highly recursive nature of it. The bright side is that once it's power is understood, parsers that previously required much use of regular expressions, =~, split, substr, chop, chomp, join, etc can now be replaced. A parser that would have taken 500 lines when written in C/C++/Java/etc can be written in 100 lines of normal Perl. When using Parse::RecDescent, it could probably be done in 20.


see also Perl, Programming, C