From: notifies s. of c. c. <per...@li...> - 2007-02-26 22:52:26
|
Revision: 107 http://svn.sourceforge.net/perl-flat/?rev=107&view=rev Author: estrabd Date: 2007-02-26 14:52:23 -0800 (Mon, 26 Feb 2007) Log Message: ----------- Modified Paths: -------------- trunk/perl-flat/lib/FLAT/DFA.pm Modified: trunk/perl-flat/lib/FLAT/DFA.pm =================================================================== --- trunk/perl-flat/lib/FLAT/DFA.pm 2007-02-26 13:31:56 UTC (rev 106) +++ trunk/perl-flat/lib/FLAT/DFA.pm 2007-02-26 22:52:23 UTC (rev 107) @@ -159,6 +159,34 @@ } +# the validity of a given string <-- executes symbols over DFA +# if there is not transition for given state and symbol, it fails immediately +# if the current state we're in is not final when symbols are exhausted, then it fails + +sub is_valid_string { + my $self = shift; + my $string = shift; + chomp $string; + my $OK = undef; + my @stack = split('',$string); + # this is confusing all funcs return arrays + my @current = $self->get_starting(); + my $current = pop @current; + foreach (@stack) { + my @next = $self->successors($current,$_); + if (!@next) { + return $OK; #<--returns undef bc no transition found + } + $current = $next[0]; + } + $OK++ if ($self->is_accepting($current)); + return $OK; +} + +# +# Experimental!! +# + # DFT stuff in preparation for DFA pump stuff; sub as_node_list { my $self = shift; @@ -282,31 +310,6 @@ return; } -# creates table used by a FLAT::DFA::Validator object to assess -# the validity of a given string <-- executes symbols over DFA -# if there is not transition for given state and symbol, it fails immediately -# if the current state we're in is not final when symbols are exhausted, then it fails - -sub is_valid_string { - my $self = shift; - my $string = shift; - chomp $string; - my $OK = undef; - my @stack = split('',$string); - # this is confusing all funcs return arrays - my @current = $self->get_starting(); - my $current = pop @current; - foreach (@stack) { - my @next = $self->successors($current,$_); - if (!@next) { - return $OK; #<--returns undef bc no transition found - } - $current = $next[0]; - } - $OK++ if ($self->is_accepting($current)); - return $OK; -} - 1; __END__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |