NAME
XML::DTD::Automaton - Perl module representing a finite automaton
SYNOPSIS
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');
ABSTRACT
XML::DTD::Automaton is a Perl module representing a finite automaton.
DESCRIPTION
XML::DTD::Automaton is a Perl module representing a finite
automaton. The following methods are provided.
- new
-
my $fsa = XML::DTD::Automaton->new;
Construct a new XML::DTD::Automaton object
- isa
-
if (XML::DTD::Automaton->isa($atd)) { ... }
Test object type
- state
-
my $idx = $fsa->mkstate('state label'); my $state = $fsa->state($idx);
Get an XML::DTD::FAState object reference from a state index
- index
-
my $state = $fsa->state($idx0); ... my $idx1 = $fsa->index($state);
Get a state index from an XML::DTD::FAState object reference
- final
-
my $flg = $fsa->final($idx);
Determine whether a state is marked final
- setfinal
-
$fsa->setfinal($idx);
Mark a state as final
- mkstate
-
my $idxa = $fsa->mkstate('state label A'); my $idxb = $fsa->mkstate('state label B', 1); # A final state
Construct a new state
- mktrans
-
$fsa->mktrans($idxa, $idxb, 'transition symbol'); $fsa->mktrans($idxa, $idxb, ''); # An epsilon transition
Construct a new transition
- rmtrans
-
$fsa->rmtrans($idxa, $idxb, 'transition symbol');
Remove a transition
- epselim
-
$fsa->epselim;
Eliminate epsilon transitions
- rmunreach
-
$fsa->rmunreach;
Remove unreachable states
- isdeterministic
-
if ($fsa->isdeterministic) { ... }
Determine with the automaton is deterministic
- accept
-
if ($fsa->accept(['a', 'a', 'b', 'c', 'a'])) { ... }
If the automaton is deterministic, determine whether the symbol sequence is accepted
- string
-
print $fsa->string;
Construct a string representation of the automaton
- writexml
-
$xo = new XML::Output({'fh' => *STDOUT}); $fsa->writexml($xo);
Write an XML representation of the automaton
SEE ALSO
AUTHOR
Brendt Wohlberg <wohl@cpan.org>
COPYRIGHT AND LICENSE
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.