line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::BatParser; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
597698
|
use utf8; |
|
10
|
|
|
|
|
99
|
|
|
10
|
|
|
|
|
52
|
|
4
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
9691
|
use Regexp::Grammars; |
|
10
|
|
|
|
|
183878
|
|
|
10
|
|
|
|
|
65
|
|
6
|
10
|
|
|
10
|
|
6029
|
use Moo; |
|
10
|
|
|
|
|
88120
|
|
|
10
|
|
|
|
|
49
|
|
7
|
10
|
|
|
10
|
|
15052
|
use namespace::autoclean; |
|
10
|
|
|
|
|
100041
|
|
|
10
|
|
|
|
|
33
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.011'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Parse DOS .bat and .cmd files |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'grammar' => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
default => sub { |
16
|
|
|
|
|
|
|
return qr{ |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
(?:<[Lines]>)* |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
(?: | |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
\:\: | REM |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
\:(?!:)[^\n]* |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
\@? |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
(?: | ) |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
| | | | | |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
echo (?: | ) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
off |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
If (?: | ) |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
| |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
NOT |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
EXIST |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
call |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Goto :? |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
set = |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
for (?:\s+DO\s+) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
NEQ | EQU | GTR | == | LSS | LEQ | GEQ |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
[^:\n\s]+ |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
[^\s]+ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
[^\n]*? |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
[^\n\s\:]* |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
}xmi; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub parse { |
71
|
9
|
|
|
9
|
1
|
47
|
my $self = shift; |
72
|
9
|
|
|
|
|
18
|
my $text = shift; |
73
|
|
|
|
|
|
|
|
74
|
9
|
50
|
|
|
|
32
|
if ( $^O eq 'MSWin32' ) { |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# First join lines splited in multiple lines |
77
|
0
|
|
|
|
|
0
|
$text =~ s/\^\n//msg; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else { |
80
|
|
|
|
|
|
|
# First join lines splited in multiple lines |
81
|
9
|
|
|
|
|
27
|
$text =~ s/\^\r\n//msg; |
82
|
9
|
|
|
|
|
48
|
$text =~ s/\r\n/\n/msg; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
9
|
50
|
|
|
|
239
|
if ( $text =~ $self->grammar ) { |
86
|
9
|
|
|
|
|
51
|
return \%/; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
else { |
89
|
0
|
|
|
|
|
|
return (); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |