Algorithm-ConstructDFA-XS
view release on metacpan or search on metacpan
lib/Algorithm/ConstructDFA/XS.pm view on Meta::CPAN
my $c = pop @todo;
next if $seen{$c}++;
my $is_nullable = !!$nullablef->($c);
my $label = $labelf->($c);
my $label_x = defined $label ? $rm->s2n($label) : undef;
# [vertex, label, nullable, start, successors...]
my @data = ($sm->s2n($c), $label_x, !!$is_nullable, $is_start{$c} // []);
for ($successorsf->($c)) {
push @data, $sm->s2n($_);
push @todo, $_;
}
push @args, \@data;
}
my %h = _internal_construct_dfa_xs(sub {
!!$acceptingf->(map { $sm->n2s($_) } @_)
}, \@args);
for (values %h) {
$_->{Combines} = [ map { $sm->n2s($_) } @{ $_->{Combines} } ];
}
for my $v (values %h) {
my $over = {};
$over->{ $rm->n2s($_) } = $v->{NextOver}{$_} for keys %{ $v->{NextOver} };
$v->{NextOver} = $over;
}
return \%h;
}
1;
__END__
=head1 NAME
Algorithm::ConstructDFA::XS - C++ version of Algorithm::ConstructDFA
=head1 SYNOPSIS
use Algorithm::ConstructDFA::XS;
my $dfa = construct_dfa_xs(...);
...
=head1 DESCRIPTION
Replacement for L<Algorithm::ConstructDFA> written in C++.
=head2 FUNCTIONS
=over
=item construct_dfa_xs(...)
Same as C<construct_dfa> in L<Algorithm::ConstructDFA>. The public
API should be the same between the two modules if the version numbers
match.
=back
=head2 EXPORTS
The function C<construct_dfa_xs> by default.
=head1 AUTHOR / COPYRIGHT / LICENSE
Copyright (c) 2014 Bjoern Hoehrmann <bjoern@hoehrmann.de>.
This module is licensed under the same terms as Perl itself.
=cut
( run in 0.318 second using v1.01-cache-2.11-cpan-bbcb1afb8fc )