Set::FA - A Set of Discrete Finite Automata
This is scripts/synopsis.1.pl:
#!/usr/bin/perl use strict; use warnings; use Set::FA; use Set::FA::Element; # -------------------------- my(@a) = map { Set::FA::Element -> new ( accepting => ['ping'], id => "a.$_", start => 'ping', transitions => [ ['ping', 'a', 'pong'], ['ping', '.', 'ping'], ['pong', 'b', 'ping'], ['pong', '.', 'pong'], ], ) } (0 .. 2); my(@b) = map { Set::FA::Element -> new ( accepting => ['pong'], id => "b.$_", start => 'ping', transitions => [ ['ping', 'a', 'pong'], ['ping', '.', 'ping'], ['pong', 'b', 'ping'], ['pong', '.', 'pong'], ], ) } (0 .. 4); my($set) = Set::FA -> new(@a, @b); my($sub_a) = $set -> accept('aaabbaaabdogbbbbbababa'); my($sub_b) = $set -> final; print 'Size of $sub_a: ', $sub_a -> size, ' (expect 3). ', 'Size of @a: ', scalar @a, ' (expect 3). ', 'Size of $sub_b: ', $sub_b -> size, ' (expect 5). ', 'Size of @b: ', scalar @b, ' (expect 5). ', "\n",
Set::FA provides a mechanism to define and run a set of DFAs.
Install Set::FA as you would for any Perl module:
Perl
Run:
cpanm Set::FA
or run:
sudo cpan Set::FA
or unpack the distro, and then either:
perl Build.PL ./Build ./Build test sudo ./Build install
or:
perl Makefile.PL make (or dmake or nmake) make test make install
This class extends Set::Object, meaning Set::FA is a subclass of Set::Object.
For the (long) list of methods available and provided by Set::Object, see that object's documentation.
"new([@list_of_dfas])" is called as my($set) = Set::FA -> new(@list_of_dfas).
my($set) = Set::FA -> new(@list_of_dfas)
It returns a new object of type Set::FA.
Set::FA
You may supply a list of Set::FA::Element objects to "new([@list_of_dfas])".
If the list is empty, you will need to call $set -> insert(@list_of_dfas) to do anything meaningful with $set.
The new object is a set whose members are all Set::FA::Element objects.
This class allows you to operate on all members of the set simultaneously, as in the synopsis.
Calls "accept($input)" in Set::FA::Element on all members of the set. This in turn calls "advance($input)" in Set::FA::Element on each member.
Note: This does not mean it calls advance() on the set object.
advance()
Returns a Set::FA object containing just the members of the original set which have ended up in their respective accepting states.
Calls "advance($input)" in Set::FA::Element on all members of the set.
Returns nothing.
Calls "final()" in Set::FA::Element on all members of the set.
Returns a Set::FA object containing just the members of the original set which are in their respective accepting states.
Returns a Set::FA object containing just the members of the original set whose ids match the $id parameter.
Returns a Set::FA object containing just the members of the original set who current state matches the $state parameter.
Here, the [] indicate an optional parameter.
The constructor. See "Constructor and Initialization".
Calls "reset()" in Set::FA::Element on all members of the set.
Calls "step($input)" in Set::FA::Element on all members of the set.
See "FAQ" in Set::FA::Element.
The file Changes was converted into Changelog.ini by Module::Metadata::Changes.
Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
The code was rewritten to perform exactly as did earlier versions (pre-1.00) of Set::FA and Set::FA::Element, and hence is essentially the same, line for line.
I've reformatted it, and changed the OO nature and the logging, obviously, but Mark Rogaski, the author of Set::FA gets the credit for the code.
I've rewritten the documentation from scratch.
Before adopting Set::FA (for Graph::Easy::Marpa's lexer), here are some other DFA modules I found on https://metacpan.org:
The author definitely knows what he's doing, but this module addresses a different issue than I face. It outputs regexps corresponding to the transitions you specify.
This is a wrapper around the State Machine Compiler, to output a SM in Perl. SMC requires Java, and can output in a range of languages. See http://smc.sourceforge.net/.
SMC looks sophisticated, but it's a rather indirect way of doing things when Perl modules such as Set::FA::Element are already available.
This module is a perl wrapper around fsa, a set of tools based on finite state automata.
fsa
See http://www.eti.pg.gda.pl/~jandac/fsa.html.
Uses a very old-fashioned style of writing Perl.
A toolkit for manipulating DFAs.
A Moose Role to convert an object into a Finite State Machine.
Build simple rules-based state machines in Perl.
Uses an old-fashioned style of writing Perl.
Looks like an unfinished thought-bubble.
Outputs a Perl module implementing the FSM you define.
A non-Perl solution.
That page has lots of interesting links.
Doesn't use a transition table, but does allow you to modify the SM while it's running. You build up a transition network diagram, labouriously, with 1 line of code at a time.
See also this Wikipedia article.
https://github.com/ronsavage/Set-FA
Email the author, or log a bug on RT:
https://rt.cpan.org/Public/Dist/Display.html?Name=Set::FA
Set::FA was written by Mark Rogaski and Ron Savage <ron@savage.net.au> in 2011.
My homepage: http://savage.net.au/index.html
Australian copyright (c) 2011, Ron Savage.
All Programs of mine are 'OSI Certified Open Source Software'; you can redistribute them and/or modify them under the terms of The Perl License, a copy of which is available at: http://www.opensource.org/licenses/index.html
To install Set::FA, copy and paste the appropriate command in to your terminal.
cpanm
CPAN shell
perl -MCPAN -e shell install Set::FA
For more information on module installation, please visit the detailed CPAN module installation guide.