From: <per...@li...> - 2006-03-10 06:00:31
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21362/lib/FLAT Modified Files: PFA.pm Log Message: made some more tweaks and trying to figure things out - ran make tests to ensure I did not screw anything up that was already working Index: PFA.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/PFA.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PFA.pm 24 Feb 2006 15:41:02 -0000 1.2 --- PFA.pm 10 Mar 2006 06:00:23 -0000 1.3 *************** *** 2,5 **** --- 2,6 ---- use strict; use base 'FLAT::NFA'; + use Carp; use FLAT::Transition; *************** *** 15,19 **** } ! # Uses FLAT::NFA methods for fall back, including: union, concat, kleene, and singleton sub as_pfa { $_[0]->clone() } --- 16,40 ---- } ! sub singleton { ! my ($class, $char) = @_; ! my $pfa = $class->new; ! ! if (not defined $char) { ! $pfa->add_states(1); ! $pfa->set_starting(0); ! } elsif ($char eq "") { ! $pfa->add_states(1); ! $pfa->set_starting(0); ! $pfa->set_accepting(0); ! } else { ! $pfa->add_states(2); ! $pfa->set_starting(0); ! $pfa->set_accepting(1); ! $pfa->set_transition(0, 1, $char); ! } ! # need to handle nodes...\ ! ! return $pfa; ! } sub as_pfa { $_[0]->clone() } *************** *** 22,33 **** # PFA->NFA conversion algorithm sub as_nfa { ! } ! # Shuffle constructor sub shuffle { } 1; --- 43,61 ---- # PFA->NFA conversion algorithm sub as_nfa { ! return FLAT::NFA->singleton(); } ! # Uses FLAT::NFA methods for fall back, including: ! # union, concat, and kleene ! ! # Shuffle constructor - pinch with lambda transitions sub shuffle { } + sub reverse { + croak "Not implemented for PFAs (yet?)"; + } + 1; |