use strict; use warnings;
package TestMLBridge;
sub parse {
my ($self, $swim, $emitter, $style) = @_;
$style ||= '';
my $receiver = "Swim::$emitter"->new;
if ($style eq 'wrap') {
$receiver->option->{wrap} = 1;
}
my $parser = Pegex::Parser->new(
grammar => 'Swim::Grammar'->new,
receiver => $receiver,
debug => $ENV{SWIM_PEGEX_DEBUG},
);
eval 'use XXX; XXX($parser->grammar->tree)'
if $ENV{SWIM_PEGEX_TREE};
$parser->parse($swim);
}
1;