line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
%strict |
2
|
|
|
|
|
|
|
%whites /(\s*(?:#.*)?\s*)+/ |
3
|
|
|
|
|
|
|
%token NUM = /([0-9]+(?:\.[0-9]*)?|\.[0-9]+)/ |
4
|
|
|
|
|
|
|
%token NAME = /([A-Za-z_][A-Za-z_0-9]*)/ |
5
|
|
|
|
|
|
|
%token OP = /([-+*\/])/ |
6
|
|
|
|
|
|
|
%token BOP = /([<>]=?|[!=]=)/ |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
%% |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
input: |
11
|
4
|
|
|
4
|
|
9
|
line.content { |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
<< 'CODE' |
14
|
|
|
|
|
|
|
sub { |
15
|
|
|
|
|
|
|
my %count = %{ shift() }; |
16
|
|
|
|
|
|
|
my $total = 0; |
17
|
|
|
|
|
|
|
$total += $_ for values %count; |
18
|
|
|
|
|
|
|
my %percent |
19
|
|
|
|
|
|
|
= $total |
20
|
|
|
|
|
|
|
? map +( $_ => $count{$_} / $total ), keys %count |
21
|
|
|
|
|
|
|
: map +( $_ => 0 ), keys %count; |
22
|
|
|
|
|
|
|
CODE |
23
|
4
|
|
|
|
|
147
|
. $content . "}\n"; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
line: |
29
|
5
|
|
|
5
|
|
11
|
stmt.stmt { "$stmt" } |
|
5
|
|
|
|
|
169
|
|
30
|
21
|
|
|
21
|
|
170
|
| line.line ';' stmt.stmt { "$line$stmt" } |
|
21
|
|
|
|
|
26
|
|
|
21
|
|
|
|
|
942
|
|
31
|
|
|
|
|
|
|
; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
stmt: |
34
|
5
|
|
|
5
|
|
181
|
/* empty */ { "" } |
35
|
|
|
|
|
|
|
/* empty */ |
36
|
|
|
|
|
|
|
| bool.exp ':' '{' line.line '}' |
37
|
1
|
|
|
1
|
|
3
|
{ $line =~ s/^/ /gm; # indent |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
38
|
1
|
|
|
|
|
35
|
" if ( $exp ) {\n$line }\n" } |
39
|
15
|
|
|
15
|
|
21
|
| bool.exp ':' $NAME { " return '$NAME'\n if $exp;\n"; } |
|
15
|
|
|
|
|
18
|
|
|
15
|
|
|
|
|
569
|
|
40
|
5
|
|
|
5
|
|
7
|
| $NAME { " return '$NAME';\n" } |
|
5
|
|
|
|
|
242
|
|
41
|
|
|
|
|
|
|
; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
bool: |
44
|
13
|
|
|
13
|
|
19
|
bool.left ',' bool.right { "$left\n && $right" } |
|
13
|
|
|
|
|
14
|
|
|
13
|
|
|
|
|
453
|
|
45
|
29
|
|
|
29
|
|
43
|
| exp.left BOP.op exp.right { "$left $op $right" } |
|
29
|
|
|
|
|
35
|
|
|
29
|
|
|
|
|
35
|
|
|
29
|
|
|
|
|
1100
|
|
46
|
|
|
|
|
|
|
; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
exp: |
50
|
23
|
|
|
23
|
|
36
|
$NUM { $NUM } |
|
23
|
|
|
|
|
880
|
|
51
|
9
|
|
|
9
|
|
12
|
| $NUM '%' { $NUM / 100 } |
|
9
|
|
|
|
|
304
|
|
52
|
27
|
|
|
27
|
|
41
|
| $NAME { "( \$count{$NAME} ||= 0 )" } |
|
27
|
|
|
|
|
1720
|
|
53
|
16
|
|
|
16
|
|
155
|
| '%' $NAME { "( \$percent{$NAME} ||= 0 )" } |
|
16
|
|
|
|
|
658
|
|
54
|
17
|
|
|
17
|
|
26
|
| exp.left OP.op exp.right { "$left $op $right" } |
|
17
|
|
|
|
|
20
|
|
|
17
|
|
|
|
|
21
|
|
|
17
|
|
|
|
|
937
|
|
55
|
0
|
|
|
0
|
|
|
| '(' exp.exp ')' { "( $exp )" } |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
%% |