Gnaw

Define parse grammars using Perl subroutine calls
Download

Gnaw Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Greg London
  • Publisher web site:
  • http://search.cpan.org/~gslondon/

Gnaw Tags


Gnaw Description

Define parse grammars using Perl subroutine calls Gnaw is a Perl module which implements full regular expressions and full text parsing grammars using nothing but pure Perl code limited to subroutine closures, exception trapping via eval, and basic Perl variables such as scalars, hashes, and arrays.You write your grammar in pure Perl. There is no intermediate "parser language" that then gets interpreted into something executable.When you do a "use Gnaw", the Gnaw module will import a number of functions directly into your namespace. Yes, this is completely bad form for normal modules. But this is not a normal module. The imported subroutines include regular expression and parsing equivalents for matching, quantifiers, literals, alternations, character classes, and so on. You build up your grammar by calling these functions. The final call will return a code reference. This code reference is your grammar.When you dereference that grammar, if it is a "match" grammar (i.e. $string =~ m//) then you pass in the string you want to parse. use Gnaw; # create the grammar my $grammar = match(lit('hello')); # apply the grammar to a string if($grammar->('hello world')) { print "match "; } else { print "no match"; }Please note that this is a beta release. This is more of a proof of concept than something ready for production code or for massive grammars. The interfaces may change completely in the future. When the interfaces have settled, I will release this as a version 1.0+ module. Until then, please do not use this to develop some gigantic parser when the grammar may have to completely change. Requirements: · Perl


Gnaw Related Software