You can subscribe to this list here.
2006 |
Jan
|
Feb
(32) |
Mar
(25) |
Apr
(13) |
May
(3) |
Jun
|
Jul
|
Aug
(1) |
Sep
(5) |
Oct
(2) |
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
(28) |
Mar
(6) |
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <per...@li...> - 2006-04-19 15:27:47
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10957/lib/FLAT Modified Files: PFA.pm Log Message: ... Index: PFA.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/PFA.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PFA.pm 18 Apr 2006 21:50:17 -0000 1.9 --- PFA.pm 19 Apr 2006 15:27:43 -0000 1.10 *************** *** 5,9 **** use FLAT::Transition; ! sub new { my $pkg = shift; --- 5,21 ---- use FLAT::Transition; ! ! # ! # Note: in a PFA, states are made up of active nodes. In this implementation, we have ! # decided to retain the functionality of the state functions in FA.pm, although the entities ! # being manipulated are technically nodes, not states. States are only explicitly tracked ! # once the PFA is serialized into an NFA. Therefore, the TRANS member of the PFA object is ! # the nodal transition function, gamma. The state transition function, delta, is not used ! # in anyway, but is derived out of the PFA->NFA conversion process. ! # ! ! # The new way of doing things eliminated from PFA.pm of FLAT::Legacy is the ! # need to explicitly track: start nodes, final nodes, symbols, and lambda & epsilon symbols, ! sub new { my $pkg = shift; *************** *** 11,21 **** --- 23,139 ---- $self->{TIED} = []; # tracks tied nodes $self->{ACTIVE_NODES} = []; # tracks active nodes - could be label like start and final + $self->{LAMBDA} = '#lambda'; # special lambda symbol - used internally return $self; } + # Singleton is no different than the NFA singleton + 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); + } + return $pfa; + } + + # attack of the clones + sub as_pfa { $_[0]->clone() } + + + # set lambda symbol - temp fix for larger problem of special symbols + # like epsilon and lambda + sub set_lambda { + my $self = shift; + $self->{LAMBDA} = $_[0]; + } + + # get lamnda symbol + sub get_lambda { + my $self = shift; + return $self->{LAMBDA}; + } + + # will implement the joining of two PFAs with lambda transitions sub shuffle { croak "PFA::shuffle is not yet supported"; + # can't use _swallow, but might be able to use a modifed version of it... + # look at FLAT::Legacy + } + + <<<<<<< PFA.pm + # joins two PFAs in a union (or) + sub union { + my @pfas = map { $_->as_pfa } @_; + my $result = $pfas[0]->clone; + $result->_swallow($_) for @pfas[1 .. $#pfas]; + $result; + } + + # joins two PFAs via concatenation + sub concat { + my @pfas = map { $_->as_pfa } @_; + + my $result = $pfas[0]->clone; + my @newstate = ([ $result->get_states ]); + my @start = $result->get_starting; + + for (1 .. $#pfas) { + push @newstate, [ $result->_swallow( $pfas[$_] ) ]; + } + + $result->unset_accepting($result->get_states); + $result->unset_starting($result->get_states); + $result->set_starting(@start); + + for my $pfa_id (1 .. $#pfas) { + for my $s1 ($pfas[$pfa_id-1]->get_accepting) { + for my $s2 ($pfas[$pfa_id]->get_starting) { + $result->set_transition( + $newstate[$pfa_id-1][$s1], + $newstate[$pfa_id][$s2], "" ); + }} + } + + $result->set_accepting( + @{$newstate[-1]}[ $pfas[-1]->get_accepting ] ); + + $result; + } + + # forms closure around a the given PFA + sub kleene { + my $result = $_[0]->clone; + + my ($newstart, $newfinal) = $result->add_states(2); + + $result->set_transition($newstart, $_, "") + for $result->get_starting; + $result->unset_starting( $result->get_starting ); + $result->set_starting($newstart); + + $result->set_transition($_, $newfinal, "") + for $result->get_accepting; + $result->unset_accepting( $result->get_accepting ); + $result->set_accepting($newfinal); + + $result->set_transition($newstart, $newfinal, ""); + $result->set_transition($newfinal, $newstart, ""); + + $result; } + # reversal should be like the transpose of the nodal transitoin + # matrix, but I still have to make sure sub reverse { croak "PFA::reverse is not yet supported"; |
From: <per...@li...> - 2006-04-19 15:27:46
|
Update of /cvsroot/perl-flat/perl-flat/dev-scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10957/dev-scripts Modified Files: pregex-to-pfa.pl Log Message: ... Index: pregex-to-pfa.pl =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/dev-scripts/pregex-to-pfa.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pregex-to-pfa.pl 18 Apr 2006 21:50:17 -0000 1.5 --- pregex-to-pfa.pl 19 Apr 2006 15:27:42 -0000 1.6 *************** *** 10,18 **** # This is mainly my test script for FLAT::FA::PFA.pm ! my $PRE = FLAT::Regex::WithExtraOps->new('(ab+c*)[xyz](a+b)*'); ! my $PFA = $PRE->as_pfa(); ! print Dumper($PFA); - print $PRE->as_string; --- 10,19 ---- # This is mainly my test script for FLAT::FA::PFA.pm ! my $PRE = FLAT::Regex::WithExtraOps->new('ab&c'); ! print Dumper($PRE); ! exit; ! ! my $PFA = $PRE->as_pfa(); |
From: <per...@li...> - 2006-04-19 15:27:46
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10957/lib/FLAT/Regex Modified Files: WithExtraOps.pm Log Message: ... Index: WithExtraOps.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex/WithExtraOps.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WithExtraOps.pm 12 Apr 2006 04:28:28 -0000 1.7 --- WithExtraOps.pm 19 Apr 2006 15:27:43 -0000 1.8 *************** *** 47,51 **** } ! sub as_pfa { croak "Negate is not supported for RE->NFA"; } --- 47,51 ---- } ! sub as_nfa { croak "Negate is not supported for RE->NFA"; } |
From: <per...@li...> - 2006-04-18 21:50:20
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4239/lib/FLAT Modified Files: NFA.pm PFA.pm Added Files: Symbol.pm Log Message: more working on PFA and figuring things out...added Symbol class, but nothing is implemented or in use - really just a concept right now Index: NFA.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/NFA.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NFA.pm 1 Mar 2006 18:29:22 -0000 1.10 --- NFA.pm 18 Apr 2006 21:50:17 -0000 1.11 *************** *** 41,58 **** $result->_swallow($_) for @nfas[1 .. $#nfas]; - # my @newstate = ([ $result->get_states ]); - # for (1 .. $#nfas) { - # push @newstate, [ $result->_swallow( $nfas[$_] ) ]; - # } - - # my $newstart = $result->add_states(1); - # $result->unset_starting($result->get_states); - # $result->set_starting($newstart); - - # for my $nfa_id (0 .. $#nfas) { - # $result->set_transition( $newstart, $newstate[$nfa_id][$_], "" ) - # for $nfas[$nfa_id]->get_starting; - # } - $result; } --- 41,44 ---- Index: PFA.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/PFA.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PFA.pm 12 Apr 2006 04:28:28 -0000 1.8 --- PFA.pm 18 Apr 2006 21:50:17 -0000 1.9 *************** *** 1,16 **** package FLAT::PFA; use strict; ! use base 'FLAT::FA'; use Carp; use FLAT::Transition; ! ! # The new way of doing things eliminated from PFA.pm of FLAT::Legacy is the ! # need to explicitly track: ! # start nodes, final nodes, symbols, and lambda & epsilon symbols, sub new { my $pkg = shift; ! my $self = $pkg->SUPER::new(@_); ! $self->{TRANS_CLASS} = "FLAT::Transition"; $self->{TIED} = []; # tracks tied nodes $self->{ACTIVE_NODES} = []; # tracks active nodes - could be label like start and final --- 1,12 ---- package FLAT::PFA; use strict; ! use base 'FLAT::NFA'; use Carp; use FLAT::Transition; ! sub new { my $pkg = shift; ! my $self = $pkg->SUPER::new(@_); # <-- SUPER is FLAT::NFA $self->{TIED} = []; # tracks tied nodes $self->{ACTIVE_NODES} = []; # tracks active nodes - could be label like start and final *************** *** 18,106 **** } - 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); - } - return $pfa; - } - - # attack of the clones - sub as_pfa { $_[0]->clone() } - sub shuffle { croak "PFA::shuffle is not yet supported"; } - sub union { - my @pfas = map { $_->as_pfa } @_; - my $result = $pfas[0]->clone; - $result->_swallow($_) for @pfas[1 .. $#pfas]; - $result; - } - - sub concat { - my @pfas = map { $_->as_pfa } @_; - - my $result = $pfas[0]->clone; - my @newstate = ([ $result->get_states ]); - my @start = $result->get_starting; - - for (1 .. $#pfas) { - push @newstate, [ $result->_swallow( $pfas[$_] ) ]; - } - - $result->unset_accepting($result->get_states); - $result->unset_starting($result->get_states); - $result->set_starting(@start); - - for my $pfa_id (1 .. $#pfas) { - for my $s1 ($pfas[$pfa_id-1]->get_accepting) { - for my $s2 ($pfas[$pfa_id]->get_starting) { - $result->set_transition( - $newstate[$pfa_id-1][$s1], - $newstate[$pfa_id][$s2], "" ); - }} - } - - $result->set_accepting( - @{$newstate[-1]}[ $pfas[-1]->get_accepting ] ); - - $result; - } - - sub kleene { - my $result = $_[0]->clone; - - my ($newstart, $newfinal) = $result->add_states(2); - - $result->set_transition($newstart, $_, "") - for $result->get_starting; - $result->unset_starting( $result->get_starting ); - $result->set_starting($newstart); - - $result->set_transition($_, $newfinal, "") - for $result->get_accepting; - $result->unset_accepting( $result->get_accepting ); - $result->set_accepting($newfinal); - - $result->set_transition($newstart, $newfinal, ""); - $result->set_transition($newfinal, $newstart, ""); - - $result; - } - sub reverse { croak "PFA::reverse is not yet supported"; --- 14,21 ---- --- NEW FILE: Symbol.pm --- # # Conceptual Experiment - not currently implemented anywhere... # package FLAT::Symbol use strict; use Carp; sub new { my ($pkg, $string, $type) = @_; bless { STRING => $string, TYPE => $type, }, $pkg; } sub as_string { return $_[0]->{STRING}; } sub get_type } return $_[0]->{TYPE}; } sub set_type { $_[0]->{TYPE} = $_[1]; } 1; ################## package FLAT::Symbol::Regular; use base 'FLAT::Symbol'; sub new { my $pkg = shift; my $self = $pkg->SUPER::new($_[0],'Regular'); return $self; } sub get_type { return 'Regular'; } sub set_type { croak("Sorry, can't change type for this symbol"); } 1; ################## package FLAT::Symbol::Special; use base 'FLAT::Symbol'; sub new { my $pkg = shift; my $self = $pkg->SUPER::new($_[0],'Special'); return $self; } sub get_type { return 'Special'; } sub set_type { croak("Sorry, can't change type for this symbol");} 1; __END__ =head1 NAME FLAT::Symbol - Base class for transition symbol =head1 SYNOPSIS A super class that is intended to provide a simple mechanism for storing a symbol that might be in conflict with another symbol in string form. TYPE is used to distinguish. Currenly this neither this, nor its current sub classes, Regular and Special, are used. =back |
From: <per...@li...> - 2006-04-18 21:50:20
|
Update of /cvsroot/perl-flat/perl-flat/dev-scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4239/dev-scripts Modified Files: pregex-to-pfa.pl regex-to-nfa.pl Log Message: more working on PFA and figuring things out...added Symbol class, but nothing is implemented or in use - really just a concept right now Index: regex-to-nfa.pl =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/dev-scripts/regex-to-nfa.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** regex-to-nfa.pl 22 Feb 2006 23:24:31 -0000 1.2 --- regex-to-nfa.pl 18 Apr 2006 21:50:17 -0000 1.3 *************** *** 3,6 **** --- 3,7 ---- use FLAT::Regex; use FLAT::NFA; + use Data::Dumper; @ARGV == 1 *************** *** 9,13 **** my $regex = shift; ! my $nfa = FLAT::Regex->new($regex)->as_nfa; my $dot = $nfa->as_graphviz; my $summary = $nfa->as_summary; --- 10,17 ---- my $regex = shift; ! my $re = FLAT::Regex->new($regex); ! ! my $nfa = $re->as_nfa(); ! my $dot = $nfa->as_graphviz; my $summary = $nfa->as_summary; Index: pregex-to-pfa.pl =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/dev-scripts/pregex-to-pfa.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pregex-to-pfa.pl 12 Apr 2006 04:28:28 -0000 1.4 --- pregex-to-pfa.pl 18 Apr 2006 21:50:17 -0000 1.5 *************** *** 10,14 **** # This is mainly my test script for FLAT::FA::PFA.pm ! my $PRE = FLAT::Regex::WithExtraOps->new('(ab+c*)&[xyz](a+b)*'); my $PFA = $PRE->as_pfa(); --- 10,14 ---- # This is mainly my test script for FLAT::FA::PFA.pm ! my $PRE = FLAT::Regex::WithExtraOps->new('(ab+c*)[xyz](a+b)*'); my $PFA = $PRE->as_pfa(); |
From: <per...@li...> - 2006-04-12 04:28:34
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21882/lib/FLAT/Regex Modified Files: Op.pm WithExtraOps.pm Log Message: at the point where I need to implement PFA->shuffle; twealed some of blokheads code so it was more obvious to me that op and member are sub routines. Implementation nodes can be seen at http://www.w4r3agle.net/flat/index.php?title=Estrabd%27s_Implementation_Notes Index: Op.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex/Op.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Op.pm 12 Mar 2006 05:03:50 -0000 1.6 --- Op.pm 12 Apr 2006 04:28:28 -0000 1.7 *************** *** 5,9 **** my $pkg = shift; ## flatten alike operations, i.e, "a+(b+c)" into "a+b+c" ! my @flat = map { UNIVERSAL::isa($_, $pkg) ? $_->members : $_ } @_; bless \@flat, $pkg; --- 5,9 ---- my $pkg = shift; ## flatten alike operations, i.e, "a+(b+c)" into "a+b+c" ! my @flat = map { UNIVERSAL::isa($_, $pkg) ? $_->members() : $_ } @_; bless \@flat, $pkg; *************** *** 23,27 **** sub as_string { ! my $t = $_[0]->members; return "#" if not defined $t; --- 23,27 ---- sub as_string { ! my $t = $_[0]->members(); return "#" if not defined $t; *************** *** 32,36 **** sub as_perl_regex { ! my $r = $_[0]->members; return "(?!)" if not defined $r; --- 32,36 ---- sub as_perl_regex { ! my $r = $_[0]->members(); return "(?!)" if not defined $r; *************** *** 41,49 **** sub as_nfa { ! FLAT::NFA->singleton( $_[0]->members ); } sub as_pfa { ! FLAT::PFA->singleton( $_[0]->members ); } --- 41,49 ---- sub as_nfa { ! FLAT::NFA->singleton( $_[0]->members() ); } sub as_pfa { ! FLAT::PFA->singleton( $_[0]->members() ); } *************** *** 65,74 **** sub is_empty { ! not defined $_[0]->members; } sub has_nonempty_string { my $self = shift; ! defined $self->members and length $self->members; } --- 65,74 ---- sub is_empty { ! not defined $_[0]->members(); } sub has_nonempty_string { my $self = shift; ! defined $self->members() and length $self->members(); } *************** *** 86,90 **** sub as_string { my ($self, $prec) = @_; ! my $result = $self->members->as_string($self->precedence) . "*"; return $prec > $self->precedence ? "($result)" : $result; } --- 86,90 ---- sub as_string { my ($self, $prec) = @_; ! my $result = $self->members()->as_string($self->precedence) . "*"; return $prec > $self->precedence ? "($result)" : $result; } *************** *** 92,96 **** sub as_perl_regex { my ($self, $prec) = @_; ! my $result = $self->members->as_perl_regex($self->precedence) . "*"; return $prec > $self->precedence ? "(?:$result)" : $result; } --- 92,96 ---- sub as_perl_regex { my ($self, $prec) = @_; ! my $result = $self->members()->as_perl_regex($self->precedence) . "*"; return $prec > $self->precedence ? "(?:$result)" : $result; } *************** *** 98,107 **** sub as_nfa { my $self = shift; ! $self->members->as_nfa->kleene; } sub as_pfa { my $self = shift; ! $self->members->as_pfa->kleene; } --- 98,107 ---- sub as_nfa { my $self = shift; ! $self->members()->as_nfa->kleene; } sub as_pfa { my $self = shift; ! $self->members()->as_pfa->kleene; } *************** *** 113,117 **** sub reverse { my $self = shift; ! my $op = $self->members->reverse; __PACKAGE__->new($op); } --- 113,117 ---- sub reverse { my $self = shift; ! my $op = $self->members()->reverse; __PACKAGE__->new($op); } *************** *** 122,130 **** sub has_nonempty_string { ! $_[0]->members->has_nonempty_string; } sub is_finite { ! ! $_[0]->members->has_nonempty_string; } --- 122,130 ---- sub has_nonempty_string { ! $_[0]->members()->has_nonempty_string; } sub is_finite { ! ! $_[0]->members()->has_nonempty_string; } *************** *** 141,145 **** my $result = join "", map { $_->as_string($self->precedence) } ! $self->members; return $prec > $self->precedence ? "($result)" : $result; } --- 141,145 ---- my $result = join "", map { $_->as_string($self->precedence) } ! $self->members(); return $prec > $self->precedence ? "($result)" : $result; } *************** *** 149,153 **** my $result = join "", map { $_->as_perl_regex($self->precedence) } ! $self->members; return $prec > $self->precedence ? "(?:$result)" : $result; } --- 149,153 ---- my $result = join "", map { $_->as_perl_regex($self->precedence) } ! $self->members(); return $prec > $self->precedence ? "(?:$result)" : $result; } *************** *** 155,159 **** sub as_nfa { my $self = shift; ! my @parts = map { $_->as_nfa } $self->members; $parts[0]->concat( @parts[1..$#parts] ); } --- 155,159 ---- sub as_nfa { my $self = shift; ! my @parts = map { $_->as_nfa } $self->members(); $parts[0]->concat( @parts[1..$#parts] ); } *************** *** 161,165 **** sub as_pfa { my $self = shift; ! my @parts = map { $_->as_pfa } $self->members; $parts[0]->concat( @parts[1..$#parts] ); } --- 161,165 ---- sub as_pfa { my $self = shift; ! my @parts = map { $_->as_pfa } $self->members(); $parts[0]->concat( @parts[1..$#parts] ); } *************** *** 173,177 **** sub reverse { my $self = shift; ! my @ops = CORE::reverse map { $_->reverse } $self->members; __PACKAGE__->new(@ops); } --- 173,177 ---- sub reverse { my $self = shift; ! my @ops = CORE::reverse map { $_->reverse } $self->members(); __PACKAGE__->new(@ops); } *************** *** 179,183 **** sub is_empty { my $self = shift; ! my @members = $self->members; for (@members) { return 1 if $_->is_empty; --- 179,183 ---- sub is_empty { my $self = shift; ! my @members = $self->members(); for (@members) { return 1 if $_->is_empty; *************** *** 190,194 **** return 0 if $self->is_empty; ! my @members = $self->members; for (@members) { return 1 if $_->has_nonempty_string; --- 190,194 ---- return 0 if $self->is_empty; ! my @members = $self->members(); for (@members) { return 1 if $_->has_nonempty_string; *************** *** 201,205 **** return 1 if $self->is_empty; ! my @members = $self->members; for (@members) { return 0 if not $_->is_finite; --- 201,205 ---- return 1 if $self->is_empty; ! my @members = $self->members(); for (@members) { return 0 if not $_->is_finite; *************** *** 219,223 **** my $result = join "+", map { $_->as_string($self->precedence) } ! $self->members; return $prec > $self->precedence ? "($result)" : $result; } --- 219,223 ---- my $result = join "+", map { $_->as_string($self->precedence) } ! $self->members(); return $prec > $self->precedence ? "($result)" : $result; } *************** *** 227,231 **** my $result = join "|", map { $_->as_perl_regex($self->precedence) } ! $self->members; return $prec > $self->precedence ? "(?:$result)" : $result; } --- 227,231 ---- my $result = join "|", map { $_->as_perl_regex($self->precedence) } ! $self->members(); return $prec > $self->precedence ? "(?:$result)" : $result; } *************** *** 233,237 **** sub as_nfa { my $self = shift; ! my @parts = map { $_->as_nfa } $self->members; $parts[0]->union( @parts[1..$#parts] ); } --- 233,237 ---- sub as_nfa { my $self = shift; ! my @parts = map { $_->as_nfa } $self->members(); $parts[0]->union( @parts[1..$#parts] ); } *************** *** 239,243 **** sub as_pfa { my $self = shift; ! my @parts = map { $_->as_pfa } $self->members; $parts[0]->union( @parts[1..$#parts] ); } --- 239,243 ---- sub as_pfa { my $self = shift; ! my @parts = map { $_->as_pfa } $self->members(); $parts[0]->union( @parts[1..$#parts] ); } *************** *** 250,254 **** sub reverse { my $self = shift; ! my @ops = map { $_->reverse } $self->members; __PACKAGE__->new(@ops); } --- 250,254 ---- sub reverse { my $self = shift; ! my @ops = map { $_->reverse } $self->members(); __PACKAGE__->new(@ops); } *************** *** 256,260 **** sub is_empty { my $self = shift; ! my @members = $self->members; for (@members) { return 0 if not $_->is_empty; --- 256,260 ---- sub is_empty { my $self = shift; ! my @members = $self->members(); for (@members) { return 0 if not $_->is_empty; *************** *** 265,269 **** sub has_nonempty_string { my $self = shift; ! my @members = $self->members; for (@members) { return 1 if $_->has_nonempty_string; --- 265,269 ---- sub has_nonempty_string { my $self = shift; ! my @members = $self->members(); for (@members) { return 1 if $_->has_nonempty_string; *************** *** 274,278 **** sub is_finite { my $self = shift; ! my @members = $self->members; for (@members) { return 0 if not $_->is_finite; --- 274,278 ---- sub is_finite { my $self = shift; ! my @members = $self->members(); for (@members) { return 0 if not $_->is_finite; Index: WithExtraOps.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex/WithExtraOps.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** WithExtraOps.pm 7 Apr 2006 20:14:34 -0000 1.6 --- WithExtraOps.pm 12 Apr 2006 04:28:28 -0000 1.7 *************** *** 31,35 **** sub as_string { my ($self, $prec) = @_; ! my $result = "~" . $self->members->as_string($self->precedence); return $prec > $self->precedence ? "($result)" : $result; } --- 31,35 ---- sub as_string { my ($self, $prec) = @_; ! my $result = "~" . $self->members()->as_string($self->precedence); return $prec > $self->precedence ? "($result)" : $result; } *************** *** 43,50 **** sub reverse { my $self = shift; ! my $op = $self->members->reverse; __PACKAGE__->new($op); } sub is_empty { croak "Not implemented for negated regexes"; --- 43,58 ---- sub reverse { my $self = shift; ! my $op = $self->members()->reverse; __PACKAGE__->new($op); } + sub as_pfa { + croak "Negate is not supported for RE->NFA"; + } + + sub as_pfa { + croak "Negate is not supported for PRE->PFA"; + } + sub is_empty { croak "Not implemented for negated regexes"; *************** *** 71,75 **** my $result = join "&", map { $_->as_string($self->precedence) } ! $self->members; return $prec > $self->precedence ? "($result)" : $result; } --- 79,83 ---- my $result = join "&", map { $_->as_string($self->precedence) } ! $self->members(); return $prec > $self->precedence ? "($result)" : $result; } *************** *** 82,90 **** sub as_pfa { my $self = shift; ! $self->members->as_pfa->shuffle; } sub reverse { ! croak "Not implemented for shuffled regexes, but it would be cool!"; } --- 90,100 ---- sub as_pfa { my $self = shift; ! $self->members()->as_pfa->shuffle; } sub reverse { ! my $self = shift; ! my $op = $self->members()->reverse; ! __PACKAGE__->new($op); } |
From: <per...@li...> - 2006-04-12 04:28:33
|
Update of /cvsroot/perl-flat/perl-flat/dev-scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21882/dev-scripts Modified Files: pregex-to-pfa.pl Log Message: at the point where I need to implement PFA->shuffle; twealed some of blokheads code so it was more obvious to me that op and member are sub routines. Implementation nodes can be seen at http://www.w4r3agle.net/flat/index.php?title=Estrabd%27s_Implementation_Notes Index: pregex-to-pfa.pl =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/dev-scripts/pregex-to-pfa.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pregex-to-pfa.pl 12 Mar 2006 05:03:49 -0000 1.3 --- pregex-to-pfa.pl 12 Apr 2006 04:28:28 -0000 1.4 *************** *** 4,14 **** use lib qw(../lib); use FLAT::Regex::WithExtraOps; use Data::Dumper; # This is mainly my test script for FLAT::FA::PFA.pm ! my $PRE = FLAT::Regex::WithExtraOps->new('(ab+c*)&(a+b)*'); my $PFA = $PRE->as_pfa(); print $PRE->as_string; --- 4,18 ---- use lib qw(../lib); use FLAT::Regex::WithExtraOps; + use FLAT::PFA; + use Data::Dumper; # This is mainly my test script for FLAT::FA::PFA.pm ! my $PRE = FLAT::Regex::WithExtraOps->new('(ab+c*)&[xyz](a+b)*'); my $PFA = $PRE->as_pfa(); + print Dumper($PFA); + print $PRE->as_string; |
From: <per...@li...> - 2006-04-12 04:28:33
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21882/lib/FLAT Modified Files: PFA.pm Regex.pm Log Message: at the point where I need to implement PFA->shuffle; twealed some of blokheads code so it was more obvious to me that op and member are sub routines. Implementation nodes can be seen at http://www.w4r3agle.net/flat/index.php?title=Estrabd%27s_Implementation_Notes Index: PFA.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/PFA.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PFA.pm 11 Apr 2006 04:28:51 -0000 1.7 --- PFA.pm 12 Apr 2006 04:28:28 -0000 1.8 *************** *** 12,16 **** my $pkg = shift; my $self = $pkg->SUPER::new(@_); ! $self->{NODE_TRANS_CLASS} = "FLAT::Transition"; $self->{TIED} = []; # tracks tied nodes $self->{ACTIVE_NODES} = []; # tracks active nodes - could be label like start and final --- 12,16 ---- my $pkg = shift; my $self = $pkg->SUPER::new(@_); ! $self->{TRANS_CLASS} = "FLAT::Transition"; $self->{TIED} = []; # tracks tied nodes $self->{ACTIVE_NODES} = []; # tracks active nodes - could be label like start and final *************** *** 21,25 **** my ($class, $char) = @_; my $pfa = $class->new; ! if (not defined $char) { $pfa->add_states(1); --- 21,25 ---- my ($class, $char) = @_; my $pfa = $class->new; ! if (not defined $char) { $pfa->add_states(1); *************** *** 35,40 **** $pfa->set_transition(0, 1, $char); } - # need to handle nodes...???\ - return $pfa; } --- 35,38 ---- *************** *** 44,51 **** sub shuffle { ! my @pfas = map { $_->as_pfa } @_; ! my $result = $pfas[0]->clone; ! # something like FA::_swallow, but for lambda ! $result; } --- 42,46 ---- sub shuffle { ! croak "PFA::shuffle is not yet supported"; } *************** *** 109,125 **** sub reverse { ! my $self = $_[0]->clone; ! $self->_transpose; ! ! my @start = $self->get_starting; ! my @final = $self->get_accepting; ! ! $self->unset_accepting( $self->get_states ); ! $self->unset_starting( $self->get_states ); ! ! $self->set_accepting( @start ); ! $self->set_starting( @final ); ! ! $self; } --- 104,108 ---- sub reverse { ! croak "PFA::reverse is not yet supported"; } Index: Regex.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Regex.pm 12 Mar 2006 05:03:50 -0000 1.6 --- Regex.pm 12 Apr 2006 04:28:28 -0000 1.7 *************** *** 33,37 **** use overload '""' => 'as_string'; sub as_string { ! $_[0]->op->as_string(0); } --- 33,37 ---- use overload '""' => 'as_string'; sub as_string { ! $_[0]->op()->as_string(0); } *************** *** 40,44 **** my $fmt = $opts{anchored} ? '(?:\A%s\z)' : '(?:%s)'; ! return sprintf $fmt, $self->op->as_perl_regex(0); } --- 40,44 ---- my $fmt = $opts{anchored} ? '(?:\A%s\z)' : '(?:%s)'; ! return sprintf $fmt, $self->op()->as_perl_regex(0); } *************** *** 49,57 **** sub as_nfa { ! $_[0]->op->as_nfa; } sub as_pfa { ! $_[0]->op->as_pfa; } --- 49,57 ---- sub as_nfa { ! $_[0]->op()->as_nfa(); } sub as_pfa { ! $_[0]->op()->as_pfa(); } *************** *** 94,107 **** sub reverse { my $self = shift; ! my $op = $self->op->reverse; $self->_from_op($op); } sub is_empty { ! $_[0]->op->is_empty; } sub is_finite { ! $_[0]->op->is_finite; } --- 94,107 ---- sub reverse { my $self = shift; ! my $op = $self->op()->reverse; $self->_from_op($op); } sub is_empty { ! $_[0]->op()->is_empty; } sub is_finite { ! $_[0]->op()->is_finite; } |
From: <per...@li...> - 2006-04-11 04:28:55
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4496/lib/FLAT Modified Files: PFA.pm Log Message: just another commit of non-working pfa/pre code Index: PFA.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/PFA.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PFA.pm 9 Apr 2006 19:37:31 -0000 1.6 --- PFA.pm 11 Apr 2006 04:28:51 -0000 1.7 *************** *** 35,39 **** $pfa->set_transition(0, 1, $char); } ! # need to handle nodes...\ return $pfa; --- 35,39 ---- $pfa->set_transition(0, 1, $char); } ! # need to handle nodes...???\ return $pfa; *************** *** 43,71 **** sub as_pfa { $_[0]->clone() } ! sub union { } sub concat { ! } ! sub kleene { } ! # Shuffle constructor - pinch with lambda transitions ! sub shuffle { ! } ! # PFA->NFA conversion algorithm ! sub as_nfa { ! } - # Implement? sub reverse { ! } --- 43,125 ---- sub as_pfa { $_[0]->clone() } ! sub shuffle { ! my @pfas = map { $_->as_pfa } @_; ! my $result = $pfas[0]->clone; ! # something like FA::_swallow, but for lambda ! $result; ! } + sub union { + my @pfas = map { $_->as_pfa } @_; + my $result = $pfas[0]->clone; + $result->_swallow($_) for @pfas[1 .. $#pfas]; + $result; } sub concat { + my @pfas = map { $_->as_pfa } @_; + + my $result = $pfas[0]->clone; + my @newstate = ([ $result->get_states ]); + my @start = $result->get_starting; ! for (1 .. $#pfas) { ! push @newstate, [ $result->_swallow( $pfas[$_] ) ]; ! } ! $result->unset_accepting($result->get_states); ! $result->unset_starting($result->get_states); ! $result->set_starting(@start); ! ! for my $pfa_id (1 .. $#pfas) { ! for my $s1 ($pfas[$pfa_id-1]->get_accepting) { ! for my $s2 ($pfas[$pfa_id]->get_starting) { ! $result->set_transition( ! $newstate[$pfa_id-1][$s1], ! $newstate[$pfa_id][$s2], "" ); ! }} ! } ! ! $result->set_accepting( ! @{$newstate[-1]}[ $pfas[-1]->get_accepting ] ); + $result; } ! sub kleene { ! my $result = $_[0]->clone; ! ! my ($newstart, $newfinal) = $result->add_states(2); ! ! $result->set_transition($newstart, $_, "") ! for $result->get_starting; ! $result->unset_starting( $result->get_starting ); ! $result->set_starting($newstart); ! $result->set_transition($_, $newfinal, "") ! for $result->get_accepting; ! $result->unset_accepting( $result->get_accepting ); ! $result->set_accepting($newfinal); ! $result->set_transition($newstart, $newfinal, ""); ! $result->set_transition($newfinal, $newstart, ""); ! ! $result; } sub reverse { ! my $self = $_[0]->clone; ! $self->_transpose; ! ! my @start = $self->get_starting; ! my @final = $self->get_accepting; ! ! $self->unset_accepting( $self->get_states ); ! $self->unset_starting( $self->get_states ); ! ! $self->set_accepting( @start ); ! $self->set_starting( @final ); ! ! $self; } |
From: <per...@li...> - 2006-04-09 19:37:37
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2951/lib/FLAT Modified Files: PFA.pm Log Message: ... Index: PFA.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/PFA.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PFA.pm 7 Apr 2006 20:14:34 -0000 1.5 --- PFA.pm 9 Apr 2006 19:37:31 -0000 1.6 *************** *** 6,19 **** use FLAT::Transition; ! # eliminated from PFA.pm of FLAT::Legacy is the need to explicitly track: ! ## start nodes, final nodes, symbols, and lambda & epsilon symbols, sub new { my $pkg = shift; my $self = $pkg->SUPER::new(@_); $self->{NODE_TRANS_CLASS} = "FLAT::Transition"; - # \gamma - there is no need to have a state transition - # function (at this point) because nothing is really - # done on the state level. If that is desired, one - # should just use the equivalent NFA $self->{TIED} = []; # tracks tied nodes $self->{ACTIVE_NODES} = []; # tracks active nodes - could be label like start and final --- 6,16 ---- use FLAT::Transition; ! # The new way of doing things eliminated from PFA.pm of FLAT::Legacy is the ! # need to explicitly track: ! # start nodes, final nodes, symbols, and lambda & epsilon symbols, sub new { my $pkg = shift; my $self = $pkg->SUPER::new(@_); $self->{NODE_TRANS_CLASS} = "FLAT::Transition"; $self->{TIED} = []; # tracks tied nodes $self->{ACTIVE_NODES} = []; # tracks active nodes - could be label like start and final *************** *** 43,54 **** } sub as_pfa { $_[0]->clone() } - - # PFA->NFA conversion algorithm - sub as_nfa { - - } - sub union { --- 40,46 ---- } + # attack of the clones sub as_pfa { $_[0]->clone() } sub union { *************** *** 68,71 **** --- 60,68 ---- } + # PFA->NFA conversion algorithm + sub as_nfa { + + } + # Implement? sub reverse { |
From: <per...@li...> - 2006-04-07 20:14:40
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31198/lib/FLAT/Regex Modified Files: WithExtraOps.pm Log Message: working on pfa stuff Index: WithExtraOps.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex/WithExtraOps.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** WithExtraOps.pm 12 Mar 2006 05:03:50 -0000 1.5 --- WithExtraOps.pm 7 Apr 2006 20:14:34 -0000 1.6 *************** *** 80,91 **** } - # Implement sub as_pfa { my $self = shift; } - # Implement? sub reverse { ! my $self = shift; } --- 80,90 ---- } sub as_pfa { my $self = shift; + $self->members->as_pfa->shuffle; } sub reverse { ! croak "Not implemented for shuffled regexes, but it would be cool!"; } |
From: <per...@li...> - 2006-04-07 20:14:40
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31198/lib/FLAT Modified Files: PFA.pm Log Message: working on pfa stuff Index: PFA.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/PFA.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PFA.pm 12 Mar 2006 05:03:50 -0000 1.4 --- PFA.pm 7 Apr 2006 20:14:34 -0000 1.5 *************** *** 1,14 **** ! package FLAT::PFA; # should this be FLAT::NFA::PFA ? .. might be too confusing use strict; ! use base 'FLAT::NFA'; use Carp; use FLAT::Transition; sub new { my $pkg = shift; ! my $self = $pkg->SUPER::new(@_); # Inherits constructor from NFA ! # contains states (actually nodes), alphabet, and ! # transitions like NFA $self->{TIED} = []; # tracks tied nodes $self->{ACTIVE_NODES} = []; # tracks active nodes - could be label like start and final --- 1,19 ---- ! package FLAT::PFA; use strict; ! use base 'FLAT::FA'; use Carp; use FLAT::Transition; + # eliminated from PFA.pm of FLAT::Legacy is the need to explicitly track: + ## start nodes, final nodes, symbols, and lambda & epsilon symbols, sub new { my $pkg = shift; ! my $self = $pkg->SUPER::new(@_); ! $self->{NODE_TRANS_CLASS} = "FLAT::Transition"; ! # \gamma - there is no need to have a state transition ! # function (at this point) because nothing is really ! # done on the state level. If that is desired, one ! # should just use the equivalent NFA $self->{TIED} = []; # tracks tied nodes $self->{ACTIVE_NODES} = []; # tracks active nodes - could be label like start and final |
From: <per...@li...> - 2006-03-22 03:39:23
|
Update of /cvsroot/perl-flat/perl-flat-legacy-2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12614 Modified Files: Makefile.PL Log Message: change minimum version of perl Index: Makefile.PL =================================================================== RCS file: /cvsroot/perl-flat/perl-flat-legacy-2/Makefile.PL,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Makefile.PL 15 Mar 2006 03:06:51 -0000 1.1.1.1 --- Makefile.PL 22 Mar 2006 03:39:19 -0000 1.2 *************** *** 1,3 **** ! use 5.008007; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence --- 1,3 ---- ! use 5.000005; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence |
From: <per...@li...> - 2006-03-12 05:03:53
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1200/lib/FLAT/Regex Modified Files: Op.pm WithExtraOps.pm Log Message: getting things down slowly Index: Op.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex/Op.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Op.pm 24 Feb 2006 18:42:09 -0000 1.5 --- Op.pm 12 Mar 2006 05:03:50 -0000 1.6 *************** *** 44,47 **** --- 44,51 ---- } + sub as_pfa { + FLAT::PFA->singleton( $_[0]->members ); + } + sub from_parse { my ($pkg, @item) = @_; *************** *** 97,100 **** --- 101,109 ---- } + sub as_pfa { + my $self = shift; + $self->members->as_pfa->kleene; + } + sub from_parse { my ($pkg, @item) = @_; *************** *** 150,153 **** --- 159,168 ---- } + sub as_pfa { + my $self = shift; + my @parts = map { $_->as_pfa } $self->members; + $parts[0]->concat( @parts[1..$#parts] ); + } + sub from_parse { my ($pkg, @item) = @_; *************** *** 222,225 **** --- 237,246 ---- } + sub as_pfa { + my $self = shift; + my @parts = map { $_->as_pfa } $self->members; + $parts[0]->union( @parts[1..$#parts] ); + } + sub from_parse { my ($pkg, @item) = @_; Index: WithExtraOps.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex/WithExtraOps.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WithExtraOps.pm 10 Mar 2006 06:00:24 -0000 1.4 --- WithExtraOps.pm 12 Mar 2006 05:03:50 -0000 1.5 *************** *** 4,8 **** use strict; use Carp; - use FLAT::PFA; my $PARSER = FLAT::Regex::Parser->new(qw[ alt concat star negate shuffle ]); --- 4,7 ---- *************** *** 14,22 **** } - # In the absence of a shuffle operator, the PFA will be a NFA - sub as_pfa { - FLAT::PFA->singleton( $_[0]->members ); - } - #### Precedence # 30 ::star --- 13,16 ---- *************** *** 86,94 **** } ! ## note: "reverse" conflicts with perl builtin sub reverse { my $self = shift; - my $op = $self->members->reverse; - __PACKAGE__->new($op); } --- 80,91 ---- } ! # Implement ! sub as_pfa { ! my $self = shift; ! } ! ! # Implement? sub reverse { my $self = shift; } |
From: <per...@li...> - 2006-03-12 05:03:53
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1200/lib/FLAT Modified Files: PFA.pm Regex.pm Log Message: getting things down slowly Index: PFA.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/PFA.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PFA.pm 10 Mar 2006 06:00:23 -0000 1.3 --- PFA.pm 12 Mar 2006 05:03:50 -0000 1.4 *************** *** 43,51 **** # 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 --- 43,60 ---- # PFA->NFA conversion algorithm sub as_nfa { ! } ! sub union { ! ! } ! ! sub concat { ! ! } ! ! sub kleene { ! ! } # Shuffle constructor - pinch with lambda transitions *************** *** 54,59 **** } sub reverse { ! croak "Not implemented for PFAs (yet?)"; } --- 63,69 ---- } + # Implement? sub reverse { ! } Index: Regex.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Regex.pm 24 Feb 2006 18:42:09 -0000 1.5 --- Regex.pm 12 Mar 2006 05:03:50 -0000 1.6 *************** *** 52,55 **** --- 52,58 ---- } + sub as_pfa { + $_[0]->op->as_pfa; + } #### regular language standard interface implementation: |
From: <per...@li...> - 2006-03-12 05:03:53
|
Update of /cvsroot/perl-flat/perl-flat/dev-scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1200/dev-scripts Modified Files: pregex-to-pfa.pl Log Message: getting things down slowly Index: pregex-to-pfa.pl =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/dev-scripts/pregex-to-pfa.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pregex-to-pfa.pl 10 Mar 2006 06:00:23 -0000 1.2 --- pregex-to-pfa.pl 12 Mar 2006 05:03:49 -0000 1.3 *************** *** 12,20 **** my $PFA = $PRE->as_pfa(); - my $NFA = $PFA->as_nfa(); - - my $DFA = $NFA->as_dfa(); - - my $DFA_min = $DFA->as_min_dfa(); - print $PRE->as_string; --- 12,14 ---- |
From: <per...@li...> - 2006-03-10 06:00:32
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21362/lib/FLAT/Regex Modified Files: WithExtraOps.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: WithExtraOps.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex/WithExtraOps.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WithExtraOps.pm 24 Feb 2006 15:41:03 -0000 1.3 --- WithExtraOps.pm 10 Mar 2006 06:00:24 -0000 1.4 *************** *** 4,16 **** use strict; use Carp; my $PARSER = FLAT::Regex::Parser->new(qw[ alt concat star negate shuffle ]); sub _parser { $PARSER } #### Precedence # 30 ::star # 20 ::concat ! # 15 ::negate <---<< ! # 12 ::shuffle <---<< # 10 ::alt # 0 ::atomic --- 4,27 ---- use strict; use Carp; + use FLAT::PFA; my $PARSER = FLAT::Regex::Parser->new(qw[ alt concat star negate shuffle ]); sub _parser { $PARSER } + sub members { + my $self = shift; + wantarray ? @$self[0 .. $#$self] : $self->[0]; + } + + # In the absence of a shuffle operator, the PFA will be a NFA + sub as_pfa { + FLAT::PFA->singleton( $_[0]->members ); + } + #### Precedence # 30 ::star # 20 ::concat ! # 15 ::negate <---<< WithExtraOps ! # 12 ::shuffle <---<< WithExtraOps # 10 ::alt # 0 ::atomic *************** *** 57,60 **** --- 68,72 ---- package FLAT::Regex::Op::shuffle; use base 'FLAT::Regex::Op'; + use Carp; sub parse_spec { "%s(2.. /[&]/)" } *************** *** 69,83 **** } - sub shuffle { - my $self = shift; - # will handle shuffle operatation - } - - sub as_pfa { - my $self = shift; - # ... will turn shuffle instance into PFA - similar to Op->alt->as_nfa, - # but a tiny different...if I may offer you a riddle :) - } - sub from_parse { my ($pkg, @item) = @_; --- 81,84 ---- *************** *** 85,118 **** } sub reverse { my $self = shift; ! my @ops = map { $_->reverse } $self->members; ! __PACKAGE__->new(@ops); } sub is_empty { ! my $self = shift; ! my @members = $self->members; ! for (@members) { ! return 1 if $_->is_empty; ! } ! return 0; } sub has_nonempty_string { ! my $self = shift; ! my @members = $self->members; ! for (@members) { ! return 1 if $_->has_nonempty_string; ! } ! return 0; } sub is_finite { ! my $self = shift; ! my @members = $self->members; ! for (@members) { ! return 0 if not $_->is_finite; ! } ! return 1; } --- 86,105 ---- } + ## note: "reverse" conflicts with perl builtin sub reverse { my $self = shift; ! my $op = $self->members->reverse; ! __PACKAGE__->new($op); } sub is_empty { ! croak "Not implemented for shuffled regexes"; } sub has_nonempty_string { ! croak "Not implemented for shuffled regexes"; } sub is_finite { ! croak "Not implemented for shuffled regexes"; } |
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; |
From: <per...@li...> - 2006-03-10 06:00:30
|
Update of /cvsroot/perl-flat/perl-flat/dev-scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21362/dev-scripts Modified Files: pregex-to-pfa.pl 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: pregex-to-pfa.pl =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/dev-scripts/pregex-to-pfa.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pregex-to-pfa.pl 10 Mar 2006 04:04:33 -0000 1.1 --- pregex-to-pfa.pl 10 Mar 2006 06:00:23 -0000 1.2 *************** *** 3,9 **** use lib qw(../lib); - use FLAT; - use FLAT::NFA; - use FLAT::Regex; use FLAT::Regex::WithExtraOps; use Data::Dumper; --- 3,6 ---- *************** *** 11,15 **** # This is mainly my test script for FLAT::FA::PFA.pm ! my $PRE = FLAT::Regex::WithExtraOps->new('ab+c*&(a+b)*'); print $PRE->as_string; --- 8,20 ---- # This is mainly my test script for FLAT::FA::PFA.pm ! my $PRE = FLAT::Regex::WithExtraOps->new('(ab+c*)&(a+b)*'); ! ! my $PFA = $PRE->as_pfa(); ! ! my $NFA = $PFA->as_nfa(); ! ! my $DFA = $NFA->as_dfa(); ! ! my $DFA_min = $DFA->as_min_dfa(); print $PRE->as_string; |
From: <per...@li...> - 2006-03-10 04:04:43
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT/Regex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15936/lib/FLAT/Regex Removed Files: WithNegations.pm Log Message: saving tonight's minor work :) --- WithNegations.pm DELETED --- |
From: <per...@li...> - 2006-03-10 04:04:43
|
Update of /cvsroot/perl-flat/perl-flat/dev-scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15936/dev-scripts Modified Files: bdetest.pl Added Files: pregex-to-pfa.pl Log Message: saving tonight's minor work :) --- NEW FILE: pregex-to-pfa.pl --- #!/usr/bin/env perl -l use strict; use lib qw(../lib); use FLAT; use FLAT::NFA; use FLAT::Regex; use FLAT::Regex::WithExtraOps; use Data::Dumper; # This is mainly my test script for FLAT::FA::PFA.pm my $PRE = FLAT::Regex::WithExtraOps->new('ab+c*&(a+b)*'); print $PRE->as_string; Index: bdetest.pl =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/dev-scripts/bdetest.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** bdetest.pl 23 Feb 2006 20:43:19 -0000 1.5 --- bdetest.pl 10 Mar 2006 04:04:33 -0000 1.6 *************** *** 4,11 **** use lib qw(../lib); use FLAT; use FLAT::Regex::WithExtraOps; use Data::Dumper; ! my $RE = FLAT::Regex::WithExtraOps->new('ab|c* & (a|b)*'); ! print $RE->as_string; --- 4,15 ---- use lib qw(../lib); use FLAT; + use FLAT::NFA; + use FLAT::Regex; use FLAT::Regex::WithExtraOps; use Data::Dumper; ! # This is mainly my test script for FLAT::FA::PFA.pm ! my $PRE = FLAT::Regex::WithExtraOps->new('ab+c*&(a+b)*'); ! ! print $PRE->as_string; |
From: <per...@li...> - 2006-03-03 15:17:52
|
Update of /cvsroot/perl-flat/perl-flat/lib/FLAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10496/lib/FLAT Modified Files: FA.pm Log Message: added preliminary FLAT::FA test suite Index: FA.pm =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/lib/FLAT/FA.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FA.pm 24 Feb 2006 06:20:25 -0000 1.8 --- FA.pm 3 Mar 2006 15:17:44 -0000 1.9 *************** *** 218,222 **** my @useless = grep { !$seen{$_} } $self->get_states; ! $self->delete_state(@useless); return @useless; --- 218,222 ---- my @useless = grep { !$seen{$_} } $self->get_states; ! $self->delete_states(@useless); return @useless; |
From: <per...@li...> - 2006-03-03 15:17:49
|
Update of /cvsroot/perl-flat/perl-flat/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10496/t Modified Files: 01-regex.t Added Files: 02-fa.t Log Message: added preliminary FLAT::FA test suite --- NEW FILE: 02-fa.t --- use Test::More tests => 48; use FLAT; my $fa = FLAT::FA->new; is( ref $fa, "FLAT::FA", "blessed reference returned" ); is_deeply( [ $fa->get_states ], [], "initially no states" ); is( $fa->num_states, 0, "initially no states" ); ok( ! $fa->is_state(0), "initially no states" ); my @s = $fa->add_states(5); is( scalar(@s), 5, "add_states returns list" ); is( $fa->num_states, 5, "add_states adds states" ); is_deeply( [ sort $fa->get_states ], [ sort @s ], "add_states add states" ); for (@s) { ok( $fa->is_state($_), "add_states returns valid states" ); } my $del = pop @s; $fa->delete_states($del); is( $fa->num_states, 4, "delete_states deletes states" ); is_deeply( [ sort $fa->get_states ], [ sort @s ], "delete_states deletes states" ); ok( ! $fa->is_state($del), "delete_states delete states" ); is_deeply( [ $fa->get_accepting ], [], "initially no accepting states" ); is_deeply( [ $fa->get_starting ], [], "initially no starting states" ); $fa->set_accepting(@s[0,1,2]); $fa->set_starting(@s[2,3]); is_deeply( [ sort $fa->get_accepting ], [ sort @s[0,1,2] ], "set_accepting sets accepting" ); is_deeply( [ sort $fa->get_starting ], [ sort @s[2,3] ], "set_starting sets starting" ); ok( $fa->is_starting( $s[2] ), "set_starting sets starting" ); ok( ! $fa->is_starting( $s[1] ), "set_starting leaves others" ); ok( $fa->is_accepting( $s[2] ), "set_accepting sets accepting" ); ok( ! $fa->is_accepting( $s[3] ), "set_accepting leaves others" ); ############# # # | a b # -----+------ # F 0 | 0,2 1 # F 1 | 3 1 # SF 2 | 1 - # S 3 | 2 2,1 use FLAT::Transition; $fa->{TRANS_CLASS} = "FLAT::Transition"; my @trans = ( [$s[0], $s[0], "a"], [$s[0], $s[1], "b"], [$s[0], $s[2], "a"], [$s[1], $s[1], "b"], [$s[1], $s[3], "a"], [$s[2], $s[1], "a"], [$s[3], $s[1], "b"], [$s[3], $s[2], "a", "b"] ); $fa->add_transition( @$_ ) for @trans; is_deeply( [ sort $fa->get_transition( @$_[0,1] )->alphabet ], [ sort @$_[2 .. $#$_] ], "transitions added correctly" ) for @trans; is( $fa->get_transition( $s[2], $s[0] ), undef, "transitions added correctly" ); is_deeply( [ sort $fa->alphabet ], [ "a", "b" ], "alphabet correct" ); my @succ = ( [ [@s[0,1]] => [@s[0,1,2,3]] ], [ [] => [] ], [ [$s[2]] => [$s[1]] ], [ $s[0] => [@s[0,1,2]] ], [ [@s[0,1]], "b" => [$s[1]] ], [ [$s[2]], "b" => [] ], [ [@s[2,3]], "a" => [@s[1,2]] ], [ $s[0], "a" => [@s[0,2]] ], [ $s[0], "c" => [] ], [ $s[3], "b" => [@s[1,2]] ], [ [@s[0,1]], ["a","b"] => [@s[0,1,2,3]] ], [ [@s[0,1,2,3]], [] => [@s[0,1,2,3]] ], [ $s[0], ["a","b"] => [@s[0,1,2]] ], ); for (@succ) { my @args = @$_; my $expected = pop @args; is_deeply( [ sort $fa->successors(@args) ], [ sort @$expected ], "successors" ); } $fa->remove_transition( $s[0], $s[1] ); is( $fa->get_transition( $s[0], $s[1] ), undef, "remove_transition" ); $fa->prune; is( $fa->num_states, 3, "prune" ); Index: 01-regex.t =================================================================== RCS file: /cvsroot/perl-flat/perl-flat/t/01-regex.t,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** 01-regex.t 24 Feb 2006 18:42:09 -0000 1.4 --- 01-regex.t 3 Mar 2006 15:17:44 -0000 1.5 *************** *** 1,6 **** ! use Test::More tests => 65; use FLAT; ! use Data::Dumper; my $reg; --- 1,6 ---- ! use Test::More tests => 66; use FLAT; ! # use Data::Dumper; my $reg; *************** *** 8,11 **** --- 8,15 ---- sub regex { FLAT::Regex->new(@_) } + is( ref regex("a"), + "FLAT::Regex", + "blessed reference" ); + is( regex( "(((a)bc)def)ghi" )->as_string, "abcdefghi", |
From: <per...@li...> - 2006-03-03 05:55:53
|
Update of /cvsroot/perl-flat/perl-flat-legacy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24009 Modified Files: MANIFEST Log Message: Index: MANIFEST =================================================================== RCS file: /cvsroot/perl-flat/perl-flat-legacy/MANIFEST,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MANIFEST 3 Mar 2006 05:53:52 -0000 1.7 --- MANIFEST 3 Mar 2006 05:55:50 -0000 1.8 *************** *** 39,40 **** --- 39,41 ---- lib/FLAT/FA/RE.pm lib/FLAT/FA/PRE.pm + dev-scripts/pretest.pl |
From: <per...@li...> - 2006-03-03 05:53:54
|
Update of /cvsroot/perl-flat/perl-flat-legacy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22780 Modified Files: MANIFEST Log Message: updated MANIFEST Index: MANIFEST =================================================================== RCS file: /cvsroot/perl-flat/perl-flat-legacy/MANIFEST,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MANIFEST 27 Feb 2006 17:42:17 -0000 1.6 --- MANIFEST 3 Mar 2006 05:53:52 -0000 1.7 *************** *** 2,9 **** --- 2,36 ---- Makefile.PL MANIFEST + META.yml README t/FLAT.t t/FLAT-FA-RE.t t/FLAT-FA-PRE.t + samples/bench.pl + samples/dfa2re.pl + samples/dfatest.pl + samples/make.tests.pl + samples/nfatest.pl + samples/pfa2nfa.pl + samples/pfatest.pl + samples/pre2dfa.stress.pl + samples/pretest.pl + samples/re2nfa.pl + samples/re2nfa.stress.pl + samples/retest.pl + t/FLAT-FA-PRE.t + t/FLAT-FA-RE.t + t/FLAT.t + t/input/dfa.1 + t/input/nfa.1 + t/input/nfa.2 + t/input/nfa.3 + t/input/nfa.4 + t/input/nfa.5 + t/input/nfa.6 + t/input/nfa.7 + t/input/pfa.1 + t/input/pfa.2 + t/input/pfa.3 lib/FLAT/FA.pm lib/FLAT/FA/DFA.pm *************** *** 12,14 **** lib/FLAT/FA/RE.pm lib/FLAT/FA/PRE.pm - --- 39,40 ---- |