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

    Marpa::R2 2.020000

    Download button

    No screenshots available
    Downloads: 195  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Jeffrey Kegler | More programs
    Perl Artistic License / FREE
    September 22nd, 2012, 12:23 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Marpa::R2 description

    Release 2 of Marpa

    Marpa parses any language whose grammar can be written in BNF. That includes recursive grammars, infinitely ambiguous grammars, ambiguous grammars and grammars with useless or empty productions.

    Marpa's advanced features, and full reference details of all features, can be found in the other Marpa API documents.

    SYNOPSIS

     use Marpa::R2;

     my $grammar = Marpa::R2::Grammar->new(
     { start => 'Expression',
     actions => 'My_Actions',
     default_action => 'first_arg',
     rules => [
     { lhs => 'Expression', rhs => [qw/Term/] },
     { lhs => 'Term', rhs => [qw/Factor/] },
     { lhs => 'Factor', rhs => [qw/Number/] },
     { lhs => 'Term', rhs => [qw/Term Add Term/], action => 'do_add' },
     { lhs => 'Factor',
     rhs => [qw/Factor Multiply Factor/],
     action => 'do_multiply'
     },
     ],
     }
     );

     $grammar->precompute();

     my $recce = Marpa::R2::Recognizer->new( { grammar => $grammar } );

     $recce->read( 'Number', 42 );
     $recce->read( 'Multiply', );
     $recce->read( 'Number', 1 );
     $recce->read( 'Add', );
     $recce->read( 'Number', 7 );

     sub My_Actions::do_add {
     my ( undef, $t1, undef, $t2 ) = @_;
     return $t1 + $t2;
     }

     sub My_Actions::do_multiply {
     my ( undef, $t1, undef, $t2 ) = @_;
     return $t1 * $t2;
     }

     sub My_Actions::first_arg { shift; return shift; }

     my $value_ref = $recce->value;
     my $value = $value_ref ? ${$value_ref} : 'No Parse';



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    recursive grammar | ambiguous grammar | Perl module | Perl | recursive | ambiguous

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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