|
From: <per...@li...> - 2006-02-27 17:42:24
|
Update of /cvsroot/perl-flat/flat4cpan/lib/FLAT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31851/lib/FLAT Modified Files: FA.pm Log Message: cleaning up comments Index: FA.pm =================================================================== RCS file: /cvsroot/perl-flat/flat4cpan/lib/FLAT/FA.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FA.pm 24 Feb 2006 21:27:15 -0000 1.3 --- FA.pm 27 Feb 2006 17:42:18 -0000 1.4 *************** *** 1,23 **** # $Revision$ $Date$ $Author$ - =head1 NAME - - FA - A finite automata base class - - =head1 SYNOPSIS - - use FA; - - =head1 DESCRIPTION - - This module is a base finite automata - used by NFA and DFA to encompass - common functions. It is probably of no use - other than to organize the DFA and NFA modules. - - B<Methods> - - =cut - package FLAT::FA; --- 1,4 ---- *************** *** 28,39 **** use Data::Dumper; - =over 18 - - =item C<set_start> - - Sets start state, calls FA->add_state - - =cut - sub set_start { my $self = shift; --- 9,12 ---- *************** *** 46,55 **** } - =item C<get_start> - - Returns start state name as string - - =cut - sub get_start { my $self = shift; --- 19,22 ---- *************** *** 57,66 **** } - =item C<is_start> - - Tests is string is the start state - - =cut - sub is_start { my $self = shift; --- 24,27 ---- *************** *** 72,81 **** } - =item C<add_state> - - Adds a state label to the state array if it does not already exist (handles dups) - - =cut - sub add_state { my $self = shift; --- 33,36 ---- *************** *** 88,97 **** } - =item C<get_states> - - Returns the array of all states - - =cut - # Returns array of states sub get_states { --- 43,46 ---- *************** *** 100,116 **** } - =item C<ensure_unique_states> - - Compares the names of the states in $self and the - provided FA, and only renames a state (in $self) - if a name collision is detected; if the disambiguation - string causes a new collision, a random string is created - using crypt() until there is no collision detected - - Usage: - $self->ensure_unique_states($NFA1,'string_to_disambiguate'); - - =cut - sub ensure_unique_states { my $self = shift; --- 49,52 ---- *************** *** 131,141 **** } - =item C<number_states> - - Numbers states 0-# of states; first appends state name with a - random string to avoid conflicts - - =cut - sub number_states { my $self = shift; --- 67,70 ---- *************** *** 157,166 **** } - =item C<append_state_names> - - Appends state names with the specified suffix - - =cut - sub append_state_names { my $self = shift; --- 86,89 ---- *************** *** 177,187 **** } - - =item C<prepend_state_names> - - Prepends state names with the specified prefix - - =cut - sub prepend_state_names { my $self = shift; --- 100,103 ---- *************** *** 198,207 **** } - =item C<is_state> - - Tests if given string is the name of a state - - =cut - # Will test if the string passed to it is the same as a label of any state sub is_state { --- 114,117 ---- *************** *** 210,220 **** } - =item C<add_final> - - Adds a list of state lables to the final states array; handles dups - and ensures state is in set of states $self->{{STATES} - - =cut - # Adds state to final (accepting) state stack sub add_final { --- 120,123 ---- *************** *** 232,241 **** } - =item C<remove_final> - - Removes the given state from $self->{_FINAL_STATES} - - =cut - sub remove_final { my $self = shift; --- 135,138 ---- *************** *** 251,260 **** } - =item C<get_final> - - Returns the array of all final states - - =cut - # Returns array of final states sub get_final { --- 148,151 ---- *************** *** 263,273 **** } - - =item C<is_final> - - Checks to see if given state is in the final state array - - =cut - # Will test if the string passed to it is the same as a label of any state sub is_final { --- 154,157 ---- *************** *** 276,285 **** } - =item C<add_symbol> - - Adds symbol to the symbol array; handles dups - - =cut - # Adds symbol sub add_symbol { --- 160,163 ---- *************** *** 293,302 **** } - =item C<is_symbol> - - Checks to see if given symbol is in the symbol array - - =cut - # Will test if the string passed to it is the same as a label of any symbol sub is_symbol { --- 171,174 ---- *************** *** 305,314 **** } - =item C<get_symbols> - - Returns array of all symbols - - =cut - # Returns array of all symbols sub get_symbols { --- 177,180 ---- *************** *** 317,326 **** } - =item C<get_transition> - - Returns hash of all transitions (symbols and next states) for given state - - =cut - # Returns a hash of all transitions (symbols and next states) for specified state sub get_transition { --- 183,186 ---- *************** *** 331,340 **** } - =item C<get_all_transitions> - - Returns hash of all transitions for all states and symbols - - =cut - sub get_all_transitions { my $self = shift; --- 191,194 ---- *************** *** 342,352 **** } - - =item C<has_transition_on> - - Tests if given state has a transition on given symbol - - =cut - sub has_transition_on { my $self = shift; --- 196,199 ---- *************** *** 360,369 **** } - =item C<has_transitions> - - Tests if given state has a transition on given symbol - - =cut - sub has_transitions { my $self = shift; --- 207,210 ---- *************** *** 376,386 **** } - - =item C<delete_transition> - - Deletes transition given the state and the symbol - - =cut - sub delete_transition { my $self = shift; --- 217,220 ---- *************** *** 393,402 **** } - =item C<to_file> - - Dumps FA to file in the proper input file format - - =cut - sub to_file { my $self = shift; --- 227,230 ---- *************** *** 408,422 **** } - =over 18 - - =item C<compliment> - - Returns compliment of 2 arrays - i.e., the items that they - do not have in common; requires arrays be passed by reference; - example: - my @compliment = $self->compliment(\@set1,\@set2); - - =cut - sub compliment { my $self = shift; --- 236,239 ---- *************** *** 446,455 **** } - =item C<is_member> - - Tests if string is in given array - - =cut - # General subroutine used to test if an element is already in an array sub is_member { --- 263,266 ---- *************** *** 462,483 **** $ret++; } - # foreach (@_) { - # if (defined($_)) { - # if ($test eq $_) { - # $ret++; - # last; - # } - # } - # } } return $ret; } - =item C<DESTROY> - - Called automatically when object is no longer needed - - =cut - sub DESTROY { return; --- 273,280 ---- *************** *** 486,490 **** 1; ! =back =head1 AUTHOR --- 283,302 ---- 1; ! __END__ ! ! =head1 NAME ! ! FA - A finite automata base class ! ! =head1 SYNOPSIS ! ! use FA; ! ! =head1 DESCRIPTION ! ! This module is a base finite automata ! used by NFA and DFA to encompass ! common functions. It is probably of no use ! other than to organize the DFA and NFA modules. =head1 AUTHOR *************** *** 510,518 **** This suite of modules started off as a homework assignment for a compiler class I took for my MS in computer science at the University of Southern ! Mississippi. =head1 COPYRIGHT This code is released under the same terms as Perl. - - =cut --- 322,328 ---- This suite of modules started off as a homework assignment for a compiler class I took for my MS in computer science at the University of Southern ! Mississippi. It then became the basis for my MS research. and thesis. =head1 COPYRIGHT This code is released under the same terms as Perl. |