line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package perltugues; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.005_62; |
4
|
1
|
|
|
1
|
|
32003
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
16153
|
use utf8; |
|
1
|
|
|
|
|
30
|
|
|
1
|
|
|
|
|
10
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.19'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
4908
|
use Filter::Simple; |
|
1
|
|
|
|
|
72906
|
|
|
1
|
|
|
|
|
9
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
FILTER_ONLY |
13
|
|
|
|
|
|
|
all => sub { |
14
|
|
|
|
|
|
|
my $package = shift; |
15
|
|
|
|
|
|
|
my %par = @_; |
16
|
|
|
|
|
|
|
my $DEBUG = $par{DEBUG} if $par{DEBUG}; |
17
|
|
|
|
|
|
|
return unless $DEBUG; |
18
|
|
|
|
|
|
|
my $i = 0; |
19
|
|
|
|
|
|
|
my @qq = /"(.*?)"/g; |
20
|
|
|
|
|
|
|
push @qq, /'(.*?)'/g; |
21
|
|
|
|
|
|
|
s/"(.*?)"/'"$' . ($i++) . '$"'/ge; |
22
|
|
|
|
|
|
|
s/'(.*?)'/"'\$" . ($i++) . "\$'"/ge; |
23
|
|
|
|
|
|
|
filter($_); |
24
|
|
|
|
|
|
|
s/"\$(\d+)\$"/'"' . (shift @qq) . '"'/ge; |
25
|
|
|
|
|
|
|
s/'\$(\d+)\$'/"'" . (shift @qq) . "'"/ge; |
26
|
|
|
|
|
|
|
Perl::Tidy::perltidy(source => \$_, destination => \$_) |
27
|
|
|
|
|
|
|
if eval "require Perl::Tidy"; |
28
|
|
|
|
|
|
|
print if $DEBUG; |
29
|
|
|
|
|
|
|
exit; |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
code_no_comments => \&filter; |
32
|
|
|
|
|
|
|
my $tipo = "inteiro|texto|real|caracter"; |
33
|
|
|
|
|
|
|
#my $tipo = '\w+'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub filter { |
36
|
1
|
|
|
1
|
0
|
4758
|
my @var; |
37
|
|
|
|
|
|
|
my @varArray; |
38
|
1
|
|
|
|
|
6
|
$_ = "use strict;$/" . $_; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
3
|
s/#.*$//g; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
3
|
s# \bse\b \s* \(? (.*?) \)? \s* \{ |
43
|
|
|
|
|
|
|
#if ($1)\{$/ |
44
|
|
|
|
|
|
|
#gmx; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
6
|
s# \bse \s* n[ãa]o |
47
|
|
|
|
|
|
|
#else |
48
|
|
|
|
|
|
|
#gmx; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
4
|
s# \ba \s+ n[aã]o \s+ ser (?:\s+ q(?:ue)? )?\b \s* (.*?) \s* \{ |
51
|
|
|
|
|
|
|
#unless ($1)\{$/ |
52
|
|
|
|
|
|
|
#gmx; |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
3
|
s# \bpara\b \s+ (\w+) \s* \( (.*?) \) \s* \{ |
55
|
|
|
|
|
|
|
#for ($2){\$$1->vale(\$_);$/ |
56
|
|
|
|
|
|
|
#gmx; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
3
|
s# \bpara\b \s+ (\w+) \s* <- \s* \(? (.*?) \)? \s* \{ |
59
|
|
|
|
|
|
|
#for ($2){\$$1->vale(\$_);$/ |
60
|
|
|
|
|
|
|
#gmx; |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
137
|
s# \bpara\b \s* \(? (.*?)\) \)? \s* \{ |
63
|
|
|
|
|
|
|
#for ($1){ |
64
|
|
|
|
|
|
|
#gmx; |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
4
|
s/ (\(?) \bde \s+ (\w+) \s+ a \s+ (\w+) (?:\s+ (?:a|para) \s+ cada \s+ (.+?) ) (\)?) |
67
|
|
|
|
|
|
|
/$1map({(\$_ * $4) + $2} 0 .. (int($3\/$4) - ($2?1:0)))$5 |
68
|
|
|
|
|
|
|
/gmx; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
4
|
s/ (\(?) \bde \s+ (\w+) \s+ a \s+ (\w+) (\)?) |
71
|
|
|
|
|
|
|
/$1$2 .. $3$4 |
72
|
|
|
|
|
|
|
/gmx; |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
3
|
s# \benquanto\b \s* \(? (.*?) \)? \s*\{ |
75
|
|
|
|
|
|
|
#while ($1)\{$/ |
76
|
|
|
|
|
|
|
#gmx; |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
12
|
s# \bat(?:eh?|é) (?:\s+q(?:ue)?)?\b \s* (\()? (.*?) \)? \{ |
79
|
|
|
|
|
|
|
#until($2)\{$/ |
80
|
|
|
|
|
|
|
#gmx; |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
3
|
s/ \bescrev[ae]\b \s* \(? (.*?) \)? (;) |
83
|
|
|
|
|
|
|
/print($1)$2 |
84
|
|
|
|
|
|
|
/gmx; |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
3
|
s/\bleia\b(?:\s*\(?(.*?)\)?)?\s*;/chomp(my \$_tmp_=<>);\$$1->vale(\$_tmp_);/g; |
87
|
1
|
|
|
|
|
3
|
s/\bsaia do (?:loop|la[cç]o)\b/last/g; |
88
|
1
|
|
|
|
|
5
|
s/\bpr[óo]ximo\b/next/g; |
89
|
1
|
|
|
|
|
3
|
s/\bde novo\b/redo/g; |
90
|
1
|
|
|
|
|
13
|
s/\brefa[çc]a\b/redo/g; |
91
|
1
|
|
|
|
|
5
|
s/\bv[aá] para\b/goto/g; |
92
|
1
|
|
|
|
|
2
|
s/\(([^()]*?)\)\s*separado\s+por\s*((["']?).*?\3)(\s*[,;])/join($2, $1)$4/g; |
93
|
1
|
|
|
|
|
3
|
s#quebra\s+de\s+linha#\$/#g; |
94
|
1
|
|
|
|
|
124
|
s#fim de texto#"\\0"#g; |
95
|
1
|
|
|
|
|
6
|
s/\bin[íi]cio:?\b/{/g; |
96
|
1
|
|
|
|
|
3
|
s/\bfim\b/}/g; |
97
|
1
|
|
|
|
|
4
|
s/\bfun[cç][aã]o\b/sub/g; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
### ___ Tipos Array ___ ### |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
{ |
102
|
1
|
|
|
|
|
2
|
my @varB = grep {!/^\s*$/} m#\barray\s+(?:$tipo)\s*:\s*([]\w, []+)\s*;#gsm; |
|
1
|
|
|
|
|
81
|
|
|
0
|
|
|
|
|
0
|
|
103
|
1
|
|
|
|
|
3
|
@varB = map {/^(\w+)/; $1} @varB; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
104
|
1
|
|
|
|
|
6
|
push(@varArray, split /\s*,\s*/, join ",", @varB); |
105
|
|
|
|
|
|
|
|
106
|
1
|
|
|
|
|
3
|
my $redef = (grep{my $v=$_; 1 < grep {$v eq $_} @varArray} @varArray)[0]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
107
|
1
|
50
|
|
|
|
4
|
die qq#Variavel "$redef" redefinida!$/# if defined $redef; |
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
4
|
my $err_var = (grep{!/^[a-z,A-Z]/} @varArray)[0]; |
|
0
|
|
|
|
|
0
|
|
110
|
1
|
50
|
|
|
|
3
|
die qq#Nome invalido da variavel "$err_var".$/# if defined $err_var; |
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
2
|
my($t, $v); |
113
|
1
|
|
|
|
|
187
|
my %tipo = m#\barray\s+($tipo)\s*:\s*([]\w, []+)\s*;#gxsm; |
114
|
1
|
|
|
|
|
5
|
for my $t(keys %tipo){ |
115
|
0
|
|
|
|
|
0
|
$_ = "use perltugues::$t;$/" . $_; |
116
|
|
|
|
|
|
|
} |
117
|
0
|
|
|
|
|
0
|
s#\barray\s+($tipo)\s*:\s*([]\w, []+)\s*; |
118
|
|
|
|
|
|
|
#my $_tipo = $1; |
119
|
0
|
|
|
|
|
0
|
my $_var = $2; |
120
|
0
|
0
|
|
|
|
0
|
join$/,map{ |
121
|
0
|
|
|
|
|
0
|
"my \@$1 = (" . (join",", ("perltugues::$_tipo->new") x $2) . ");" |
122
|
|
|
|
|
|
|
if /^(\w+)\[(\d+)\]$/ |
123
|
|
|
|
|
|
|
}split/\s*,\s*/, $_var |
124
|
1
|
|
|
|
|
490
|
#gexsm; |
125
|
1
|
|
|
|
|
7
|
for my $var(@varArray){ |
126
|
0
|
|
|
|
|
0
|
s/\btamanho\s*\($var\)/scalar \@$var/g; |
127
|
0
|
|
|
|
|
0
|
s/([^\$])\b$var\[(.+?)\]\s*=\s*((['"])?.*?\3?)\s*;/$1($2 <= \$#$var?\${$var}[$2]->vale($3):die qq#O array "\\$var" esta sendo acessado numa posicao inexistente\$\/#);/g; |
128
|
0
|
|
|
|
|
0
|
s/([^\$])\b$var\[(.+?)\]/$1($2 <= \$#$var?\$$var\[$2]:die qq#O array "$var" esta sendo acessado numa posicao inexistente\$\/#)/g; |
129
|
0
|
|
|
|
|
0
|
s/([^@#])\b$var\b(?!\[.*?\])/$1\@$var/g; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
### ___ Tipos Escalares ___ ### |
133
|
|
|
|
|
|
|
|
134
|
1
|
|
|
|
|
201
|
my @varB = grep {!/^\s*$/} m#\s*\b(?:$tipo)\s*:\s*([\w, ]+)\s*;#gsm; |
|
0
|
|
|
|
|
0
|
|
135
|
|
|
|
|
|
|
#my @varB = grep {!/^\s*$/} m#(?:^|;)\s*\b(?:$tipo)\s*:\s*([\w, ]+)\s*;#gsm; |
136
|
1
|
|
|
|
|
7
|
push(@var, split /\s*,\s*/, join ",", @varB); |
137
|
|
|
|
|
|
|
|
138
|
1
|
|
|
|
|
4
|
my $redef = (grep{my $v=$_; 1 < grep {$v eq $_} @var} @var)[0]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
139
|
1
|
50
|
|
|
|
4
|
die qq#Variavel "$redef" redefinida!$/# if defined $redef; |
140
|
|
|
|
|
|
|
|
141
|
1
|
|
|
|
|
4
|
my $err_var = (grep{!/^[a-z,A-Z]/} @var)[0]; |
|
0
|
|
|
|
|
0
|
|
142
|
1
|
50
|
|
|
|
3
|
die qq#Nome invalido da variavel "$err_var".$/# if defined $err_var; |
143
|
|
|
|
|
|
|
|
144
|
1
|
|
|
|
|
2
|
my($t, $v); |
145
|
1
|
|
|
|
|
750
|
my %tipo = m#\s*\b($tipo)\s*:\s*([\w, ]+)\s*;#gsmx; |
146
|
|
|
|
|
|
|
#my %tipo = m#(?:^|;)\s*\b($tipo)\s*:\s*([\w, ]+)\s*;#gsmx; |
147
|
1
|
|
|
|
|
8
|
for my $t(keys %tipo){ |
148
|
0
|
|
|
|
|
0
|
$_ = "use perltugues::$t;$/" . $_; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
#s#((?:^|;)\s*)\b($tipo)\s*:\s*([\w, ]+)\s*; |
151
|
0
|
|
|
|
|
0
|
s#(\s*)\b($tipo)\s*:\s*([\w, ]+)\s*; |
152
|
0
|
|
|
|
|
0
|
#$1 . join$/,map{"my \$$_ = perltugues::$2->new;"}split/\s*,\s*/, $3 |
153
|
1
|
|
|
|
|
81
|
#gesmx; |
154
|
1
|
|
|
|
|
11
|
for my $var(@var){ |
155
|
0
|
|
|
|
|
|
s/([^\$])\b$var\s*=\s*((['"])?.*?\3?)\s*;/$1\$$var->vale($2);/g; |
156
|
0
|
|
|
|
|
|
s/([^\$])\b$var\b/$1\$$var/g; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
}; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
42; |
162
|
|
|
|
|
|
|
__END__ |