| XML-DTD documentation | view source | Contained in the XML-DTD distribution. |
XML::DTD::Automaton - Perl module representing a finite automaton
use XML::DTD::Automaton;
my $fsa = XML::DTD::Automaton->new;
my $idxa = $fsa->mkstate('state label A');
my $idxb = $fsa->mkstate('state label B');
$fsa->mktrans($idxa, $idxb, 'transition symbol');
XML::DTD::Automaton is a Perl module representing a finite automaton.
XML::DTD::Automaton is a Perl module representing a finite automaton. The following methods are provided.
my $fsa = XML::DTD::Automaton->new;
Construct a new XML::DTD::Automaton object
if (XML::DTD::Automaton->isa($atd)) {
...
}
Test object type
my $idx = $fsa->mkstate('state label');
my $state = $fsa->state($idx);
Get an XML::DTD::FAState object reference from a state index
my $state = $fsa->state($idx0); ... my $idx1 = $fsa->index($state);
Get a state index from an XML::DTD::FAState object reference
my $flg = $fsa->final($idx);
Determine whether a state is marked final
$fsa->setfinal($idx);
Mark a state as final
my $idxa = $fsa->mkstate('state label A');
my $idxb = $fsa->mkstate('state label B', 1); # A final state
Construct a new state
$fsa->mktrans($idxa, $idxb, 'transition symbol'); $fsa->mktrans($idxa, $idxb, ''); # An epsilon transition
Construct a new transition
$fsa->rmtrans($idxa, $idxb, 'transition symbol');
Remove a transition
$fsa->epselim;
Eliminate epsilon transitions
$fsa->rmunreach;
Remove unreachable states
if ($fsa->isdeterministic) {
...
}
Determine with the automaton is deterministic
if ($fsa->accept(['a', 'a', 'b', 'c', 'a'])) {
...
}
If the automaton is deterministic, determine whether the symbol sequence is accepted
print $fsa->string;
Construct a string representation of the automaton
$xo = new XML::Output({'fh' => *STDOUT});
$fsa->writexml($xo);
Write an XML representation of the automaton
Brendt Wohlberg <wohl@cpan.org>
Copyright (C) 2006,2010 by Brendt Wohlberg
This library is available under the terms of the GNU General Public License (GPL), described in the GPL file included in this distribution.
| XML-DTD documentation | view source | Contained in the XML-DTD distribution. |