Recursive-Regex is the end result of a weekend of playing with the code I published on Thursday about adding named dispatch functions to CL-PPCRE regular expressions. I kept at it and I think that this approach might have some promise for building up a library of reusable regexp/matcher chunks. I also found that this made it somewhat easier to obtain results from the regular expression search because I get back a full parse tree rather than the bindings typically supplied by CL-PPCRE.
I have it somewhat documented, loadable and testable, with all my current tests passing. There is even a recursive regex csv parser defined in the default dispatch table (mostly as a simple, but practical proof of concept).
Comma-List: [\t ]*(?:(?<body>[^,]*)[\t ]*,)*[\t ]*(?<body>[^,]*)[\t ]*
CSV-Row: (?<comma-list>((?<double-quotes>)|[^\n,]*))(?:\n|$)
CSV-File: (?<csv-row>)*
Double quotes and body both go to custom dispatcher functions. Body defines where the body regex should be matched and what to use if no body is supplied.
I don’t really have long term plans for this project, but it scratched an intellectual itch I was experiencing. Perhaps it will be useful for someone down the road.
IIUC this is a similar thing to REs with recursive patterns, right?
http://search.cpan.org/~rgarcia/perl/pod/perl595delta.pod#Regular_expressions
How about providing an example for an S-expression parser using this?
I have not use recursive patterns in perl (or much perl) but based on the description, it sounds like this is a slightly more general system, but accomplishes perhaps the same goals
Some differences I see at a perusal:
Pingback: Recursive-Regex Update | Russ’s Tech Blog