Couldn't you just not use unproductive_ok and inaccessible_ok?
On Sep 26, 2014, at 0930 PT, Ruslan Shvedov <[email protected]> wrote:
> Unproductive and unaccessible rules can be removed from a grammar easily
> using code like this:
>
> # cleanup the grammar using Marpa NAIF
> my $grammar = Marpa::R2::Grammar->new({
> start => ...,
> rules => ...,
> unproductive_ok => 1,
> inaccessible_ok => 1,
> });
> $grammar->precompute();
>
> my $rules = $grammar->show_rules;
> my @cleaned;
> for my $rule (grep {!/unproductive|inaccessible/} split /\n/m, $rules){
> my (undef, $lhs, @rhs) = split /^\d+:\s+|\s+->\s+|\s+/, $rule;
> push @cleaned_pfg, [ $lhs, \@rhs ];
> }
>
> Working example can be seen here. Just a quick hack, but kind of cool and
> saved my day. I wonder whether such use is legitimate and, if so, can it be
> worth a special method, e.g. Marpa::R2::Grammar::cleanup().
>
> --
> You received this message because you are subscribed to the Google Groups
> "marpa parser" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"marpa parser" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.