line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Scigen; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23567
|
use 5.008001; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
59
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
45
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
1
|
|
|
1
|
|
894
|
use AutoLoader qw(AUTOLOAD); |
|
1
|
|
|
|
|
1688
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
13
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
14
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# This allows declaration use Text::Scigen ':all'; |
17
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
18
|
|
|
|
|
|
|
# will save memory. |
19
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
) ] ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT = qw( |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
|
126
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
109
|
|
32
|
1
|
|
|
1
|
|
1181
|
use Text::Autoformat; |
|
1
|
|
|
|
|
77125
|
|
|
1
|
|
|
|
|
182
|
|
33
|
1
|
|
|
1
|
|
1478
|
use Text::Scigen::scigen; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3570
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $DATA_PATH = $INC{'Text/Scigen.pm'}; |
36
|
|
|
|
|
|
|
$DATA_PATH =~ s/Scigen\.pm$//; |
37
|
|
|
|
|
|
|
$DATA_PATH .= "Scigen"; |
38
|
|
|
|
|
|
|
our $REL_PATH; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Preloaded methods go here. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new |
45
|
|
|
|
|
|
|
{ |
46
|
1
|
|
|
1
|
1
|
14
|
my( $class, %self ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
5
|
my $self = bless \%self, $class; |
49
|
|
|
|
|
|
|
|
50
|
1
|
50
|
|
|
|
4
|
Carp::croak( "Missing filename argument" ) |
51
|
|
|
|
|
|
|
if !defined $self{filename}; |
52
|
|
|
|
|
|
|
|
53
|
1
|
50
|
|
|
|
9
|
$self{filename} = "$DATA_PATH/$self{filename}" |
54
|
|
|
|
|
|
|
if $self{filename} !~ /^\//; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
4
|
$self{rel_path} = $self{filename}; |
57
|
1
|
|
|
|
|
12
|
$self{rel_path} =~ s/\/[^\/]+$//; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
50
|
|
|
9
|
$self{debug} ||= 0; |
60
|
|
|
|
|
|
|
|
61
|
1
|
50
|
|
|
|
4
|
$self{pretty} = 1 if !defined $self{pretty}; |
62
|
|
|
|
|
|
|
|
63
|
1
|
50
|
|
|
|
98
|
if( open(my $fh, "<:utf8", $self{filename}) ) { |
64
|
1
|
|
|
|
|
12
|
Text::Scigen::scigen::read_rules ( |
65
|
|
|
|
|
|
|
$fh, |
66
|
|
|
|
|
|
|
$self{dat} = {}, |
67
|
|
|
|
|
|
|
\$self{RE}, |
68
|
|
|
|
|
|
|
$self{debug}, |
69
|
|
|
|
|
|
|
$self |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
0
|
|
|
|
|
0
|
Carp::croak( "Error reading from $self{filename}: $!" ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
208
|
return $self; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub generate |
80
|
|
|
|
|
|
|
{ |
81
|
1
|
|
|
1
|
1
|
11
|
my( $self, $start ) = @_; |
82
|
|
|
|
|
|
|
|
83
|
1
|
50
|
|
|
|
8
|
$start = [$start] if ref($start) ne "ARRAY"; |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
5
|
return join "\n", map { Text::Scigen::scigen::generate ( |
|
1
|
|
|
|
|
12
|
|
86
|
|
|
|
|
|
|
$self->{dat}, |
87
|
|
|
|
|
|
|
$_, |
88
|
|
|
|
|
|
|
$self->{RE}, |
89
|
|
|
|
|
|
|
$self->{debug}, |
90
|
|
|
|
|
|
|
$self->{pretty} |
91
|
|
|
|
|
|
|
) } @$start; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _find |
95
|
|
|
|
|
|
|
{ |
96
|
1
|
|
|
1
|
|
2
|
my( $self, $filename ) = @_; |
97
|
|
|
|
|
|
|
|
98
|
1
|
50
|
|
|
|
35
|
return $filename if -e $filename; |
99
|
1
|
50
|
|
|
|
40
|
return "$self->{rel_path}/$filename" if -e "$self->{rel_path}/$filename"; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
die "Can't find $filename\n"; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
__END__ |