Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Gnaw 0.12

    Download button

    No screenshots available
    Downloads: 308  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Greg London | More programs
    Perl Artistic License / FREE
    July 16th, 2009, 21:46 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    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.


    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    grammar parser | subroutine calls | Perl module | Perl | grammar | parser

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM