Hi, I just uploaded a module I call Gnaw to CPAN. The readme file should show up here at some point:
http://www.cpan.org/modules/by-authors/id/G/GS/GSLONDON/Gnaw-0.01.readme Its a module that allows you to create regular expressions and grammars in pure perl, without using the regexp engine and without using some intermediate language that gets parsed and compiles a parser for you (i.e. the regexp engine or something like parse::recdescent) It uses subroutines, sub closures, die trapped with eval{}, and perl variables, but that's pretty much it. Here's what a simple grammar might look like to do a match: use Gnaw; my $grammar = match(lit('hello')); if($grammar->('hello world')) { print "match\n"; } else { print "no match"; } I've implemented literals, character classes, quantifiers, alternations, capturing, and callbacks. named rules are implemented simply by declaring named subroutines. sub greet_all { series(lit('hello'), lit('world'));} sub greet_one { series(lit('howdy'), lit('partner'));} my $biggrammar = match(alternation(greet_all, greet_one)); It's slightly more verbose than Parse::RecDescent, but it's perl code, rather than something that gets parsed by parse recdescent and then converted into perl code. The "commit" function doesn't work and I haven't figured out how to fix it yet. But all the other functions are there and can be played around with. Fixing the problem with "commit" might require major changes to the structure, so I wouldn't recommend anyone do any production code with this, but it's an interesting beta module to play around with. complete module with POD and test suite is on its way to CPAN. Greg _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

