<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    MarpaX::Simple - Generate Marpa-based parser

VERSION
    This document describes version 0.02 of MarpaX::Simple (from Perl
    distribution MarpaX-Simple), released on 2014-05-13.

SYNOPSIS
     use MarpaX::Simple qw(gen_parser);

     my $parser = gen_parser(
         grammar =&gt; &lt;&lt;'EOG',
     :start     ::= expr
     expr       ::= num
                  | num '+' num    action =&gt; do_add
     num        ~ [\d]+
     :discard   ~ whitespace
     whitespace ~ [\s]+
     EOG
         actions =&gt; {
             do_add =&gt; sub { shift; $_[0] + $_[2] }
         },
     );

     print $parser-&gt;('3 + 4'); # -&gt; 7
     print $parser-&gt;('3 + ');  # dies with parse error

    which is a shortcut for roughly this:

     no strict 'refs';
     use Marpa::R2;
     my $grammar = Marpa::R2::Scanless::G-&gt;new({source =&gt; \$args{grammar}});
     my $pkg = "MarpaX::Simple::gen" . some_random_value();
     my $actions = $args{actions};
     for (keys %$actions) {
         ${"$pkg\::$_"} = $actions-&gt;{$_};
     }
     my $parser = sub {
         my $input = shift;
         my $recce = Marpa::R2::Scanless::R-&gt;new({
             grammar =&gt; $grammar,
             semantics_package =&gt; $pkg,
         });
     };

DESCRIPTION
    This module tries to simplify the incantation of producing a parser
    using Marpa::R2 (the scanless interface) by reducing the process to a
    single function call: "gen_parser".

FUNCTIONS
  gen_parser(%args) -&gt; code
    Generate Marpa-based parser.

    Arguments ('*' denotes required arguments):

    *   actions =&gt; *hash*

        Supply actions specified in the grammar.

    *   grammar* =&gt; *str*

    *   too_many_earley_items =&gt; *int*

        Will be passed to recognizer's constructor.

    *   trace_terminals =&gt; *bool*

        Will be passed to recognizer's constructor.

    *   trace_values =&gt; *bool*

        Will be passed to recognizer's constructor.

    Return value:

TODO
    Allow customizing error message/behavior.

    Support more grammar (Marpa::R2::Scanless::G) options, e.g.:
    "trace_file_handle".

    Support more recognizer (Marpa::R2::Scanless::R) options, e.g.:
    "max_parses", "trace_file_handle".

SEE ALSO
    Marpa::R2

HOMEPAGE
    Please visit the project's homepage at
    &lt;https://metacpan.org/release/MarpaX-Simple&gt;.

SOURCE
    Source repository is at
    &lt;https://github.com/sharyanto/perl-MarpaX-Simple&gt;.

BUGS
    Please report any bugs or feature requests on the bugtracker website
    &lt;https://rt.cpan.org/Public/Dist/Display.html?Name=MarpaX-Simple&gt;

    When submitting a bug or request, please include a test-file or a patch
    to an existing test-file that illustrates the bug or desired feature.

AUTHOR
    Steven Haryanto &lt;stevenharyanto@gmail.com&gt;

COPYRIGHT AND LICENSE
    This software is copyright (c) 2014 by Steven Haryanto.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

</pre></body></html>