Marpa::PP

Pure Perl version of Marpa
Download

Marpa::PP Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Publisher Name:
  • Jeffrey Kegler
  • Publisher web site:
  • http://search.cpan.org/~jkegl/

Marpa::PP Tags


Marpa::PP Description

Pure Perl version of Marpa Marpa::PP is a Perl module that parses any language whose grammar can be written in BNF. That includes recursive grammars, ambiguous grammars, infinitely ambiguous grammars and grammars with useless or empty productions.This document contains a top-level overview of the API for the Marpa parse engine. The two examples in this document show the typical flows of Marpa method calls. This document will use these examples to describe the basic features of Marpa in semi-tutorial fashion. Marpa's advanced features, and full reference details of all features, can be found in the other Marpa API documents.SYNOPSIS use Marpa::PP; my $grammar = Marpa::Grammar->new( { start => 'Expression', actions => 'My_Actions', default_action => 'first_arg', rules => }, { lhs => 'Term', rhs => }, { lhs => 'Factor', rhs => }, { lhs => 'Term', rhs => , action => 'do_add' }, { lhs => 'Factor', rhs => , action => 'do_multiply' }, ], } ); $grammar->precompute(); my $recce = Marpa::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'; Requirements: · Perl


Marpa::PP Related Software