Marpa

Parse any Language You Can Describe in BNF
Download

Marpa Ranking & Summary

Advertisement

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

Marpa Tags


Marpa Description

Parse any Language You Can Describe in BNF Marpa 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 the synopsis show the typical flow of calls in the Marpa API. 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 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 } ); my @tokens = ( , , , , , ); $recce->tokens( \@tokens ); 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 Related Software