From: <per...@li...> - 2006-05-28 03:39:59
|
Revision: 68 Author: estrabd Date: 2006-05-27 20:39:53 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/perl-flat/?rev=68&view=rev Log Message: ----------- I think PRE->as_pfa is complete Modified Paths: -------------- trunk/perl-flat/lib/FLAT/PFA.pm Modified: trunk/perl-flat/lib/FLAT/PFA.pm =================================================================== --- trunk/perl-flat/lib/FLAT/PFA.pm 2006-05-24 05:53:43 UTC (rev 67) +++ trunk/perl-flat/lib/FLAT/PFA.pm 2006-05-28 03:39:53 UTC (rev 68) @@ -64,18 +64,27 @@ } # will implement the joining of two PFAs with lambda transitions -# BUG - need to fix +# need to fix sub shuffle { my @pfas = map { $_->as_pfa } @_; - my $result = $pfas[0]->clone; - my @newstate = ([ $result->get_states ]); - my @start = $result->get_starting; - + # iteratively add lambda pinch to all PFAs for (1 .. $#pfas) { - push @newstate, [ $result->_swallow( $pfas[$_] ) ]; + $result->_swallow( $pfas[$_] ); + my @starting = $result->get_starting(); + my @accepting = $result->get_accepting(); + $result->unset_starting(@starting); + $result->unset_accepting(@accepting); + my ($newstart, $newfinal) = $result->add_states(2); + $result->set_starting($newstart); + $result->set_accepting($newfinal); + foreach (@starting) { + $result->set_transition($newstart,$_,'#lambda'); + } + foreach (@accepting) { + $result->set_transition($_,$newfinal,'#lambda'); + } } - return $result; } @@ -84,8 +93,9 @@ my @pfas = map { $_->as_pfa } @_; my $result = $pfas[0]->clone; $result->_swallow($_) for @pfas[1 .. $#pfas]; - $result; -} + my ($newstart, $newfinal) = $result->add_states(2); + + } # joins two PFAs via concatenation - no change from NFA sub concat { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |