FLAT/CMD/AcyclicStrings.pm untested

filter: Statementstmt 0.0% 0 / 53 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 74 CC 4 SCAR 14.8
CC
4
Cov
0%
as_strings
12.0
AUTOLOAD
6.0
BEGIN
2.0
CRAP 4.4
1 # all strings available via acyclic path from the DFA start state to any all of the final states
2  
3 package FLAT::CMD::AcyclicStrings;
4 use parent 'FLAT::CMD';
5 use FLAT;
6 use FLAT::Regex::WithExtraOps;
7 use FLAT::PFA;
8 use FLAT::NFA;
9 use FLAT::DFA;
10 use Storable;
11 use Carp;
12  
13 # Support for perl one liners - like what CPAN.pm uses #<- should move all to another file
14 use parent 'Exporter'; #instead of: use Exporter (); @ISA = 'Exporter';
15 use vars qw(@EXPORT $AUTOLOAD);
16  
17 @EXPORT = qw(as_strings);
18  
19 sub AUTOLOAD {
20 my ($l) = $AUTOLOAD;
21 $l =~ s/.*:://;
22 my (%EXPORT);
23 @EXPORT{@EXPORT} = '';
24 if (exists $EXPORT{$l}) {
25 FLAT::CMD->$l(@_);
26 }
27 }
28  
29 use vars qw(%nodes %dflabel %backtracked %low $lastDFLabel @string $dfa);
30 # acyclic - no cycles
31 sub as_strings {
32 my $PRE = shift;
33 # neat a better way to get input via stdin
34 if (!$PRE) {
35 while (<>) {
36 chomp;
37 $PRE = $_;
38 last;
39 }
40 }
41 # caches results, loads them in if detexted
42 my $RE = FLAT::Regex::WithExtraOps->new($PRE);
43 printf("%s\n", $RE->as_string());
44 if (!-e "$PRE.dat") {
45 $dfa = $RE->as_pfa->as_nfa->as_dfa->as_min_dfa->trim_sinks;
46 #store $dfa, "$PRE.dat";
47 }
48 else {
49 print STDERR "$PRE.dat found..";
50 $dfa = retrieve "$PRE.dat";
51 }
52 $dfa->as_acyclic_strings();
53 }
54  
55 1;