line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
2719
|
use strict; use warnings; |
|
4
|
|
|
4
|
|
7
|
|
|
4
|
|
|
|
|
141
|
|
|
4
|
|
|
|
|
21
|
|
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
193
|
|
2
|
|
|
|
|
|
|
package DJSON; |
3
|
|
|
|
|
|
|
our $VERSION = '0.0.8'; |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
1700
|
use Pegex; |
|
4
|
|
|
|
|
16877
|
|
|
4
|
|
|
|
|
212
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
27
|
use base 'Exporter'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
724
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw(decode_djson); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub decode_djson { |
11
|
26
|
|
|
26
|
0
|
176
|
pegex( |
12
|
|
|
|
|
|
|
djson_grammar(), |
13
|
|
|
|
|
|
|
'DJSON::Receiver', |
14
|
|
|
|
|
|
|
)->parse($_[0]); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
|
27
|
use constant djson_grammar => <<'...'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
319
|
|
18
|
|
|
|
|
|
|
%grammar djson |
19
|
|
|
|
|
|
|
%version 0.0.1 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
djson: map | seq | list |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
node: map | seq | scalar |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
map: |
26
|
|
|
|
|
|
|
/- LCURLY -/ |
27
|
|
|
|
|
|
|
pair* |
28
|
|
|
|
|
|
|
/- RCURLY -/ |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
pair: string /- COLON? -/ node /- COMMA? -/ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
seq: |
33
|
|
|
|
|
|
|
/- LSQUARE -/ |
34
|
|
|
|
|
|
|
node* %% /- COMMA? -/ |
35
|
|
|
|
|
|
|
/- RSQUARE -/ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
list: node* %% /- COMMA? -/ |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
scalar: double | single | bare |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
string: scalar |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
double: / |
44
|
|
|
|
|
|
|
DOUBLE |
45
|
|
|
|
|
|
|
([^ DOUBLE ]*) |
46
|
|
|
|
|
|
|
DOUBLE |
47
|
|
|
|
|
|
|
/ |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
single: / |
50
|
|
|
|
|
|
|
SINGLE |
51
|
|
|
|
|
|
|
([^ SINGLE ]*) |
52
|
|
|
|
|
|
|
SINGLE |
53
|
|
|
|
|
|
|
/ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
bare: /( |
56
|
|
|
|
|
|
|
[^ |
57
|
|
|
|
|
|
|
WS |
58
|
|
|
|
|
|
|
LCURLY RCURLY |
59
|
|
|
|
|
|
|
LSQUARE RSQUARE |
60
|
|
|
|
|
|
|
SINGLE DOUBLE |
61
|
|
|
|
|
|
|
COMMA |
62
|
|
|
|
|
|
|
]+ |
63
|
|
|
|
|
|
|
)/ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
ws: /(: WS | comment )/ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
comment: / HASH SPACE ANY* BREAK / |
68
|
|
|
|
|
|
|
... |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
############################################################################### |
71
|
|
|
|
|
|
|
# The receiver class can reshape the data at any given rule match. |
72
|
|
|
|
|
|
|
############################################################################### |
73
|
|
|
|
|
|
|
package DJSON::Receiver; |
74
|
4
|
|
|
4
|
|
19
|
use base 'Pegex::Tree'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
2167
|
|
75
|
4
|
|
|
4
|
|
27241
|
use boolean; |
|
4
|
|
|
|
|
14434
|
|
|
4
|
|
|
|
|
21
|
|
76
|
|
|
|
|
|
|
|
77
|
63
|
|
|
63
|
|
28999
|
sub got_string {"$_[1]"} |
78
|
23
|
|
|
23
|
|
11267
|
sub got_map { +{ map {($_->[0], $_->[1])} @{$_[1]->[0]} } } |
|
59
|
|
|
|
|
306
|
|
|
23
|
|
|
|
|
74
|
|
79
|
17
|
|
|
17
|
|
24802
|
sub got_seq { $_[1]->[0] } |
80
|
|
|
|
|
|
|
sub got_bare { |
81
|
103
|
|
|
103
|
|
73893
|
$_ = pop; |
82
|
103
|
100
|
|
|
|
1040
|
/true/ ? true : |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
83
|
|
|
|
|
|
|
/false/ ? false : |
84
|
|
|
|
|
|
|
/null/ ? undef : |
85
|
|
|
|
|
|
|
/^( |
86
|
|
|
|
|
|
|
-? |
87
|
|
|
|
|
|
|
(?: 0 | [1-9] [0-9]* ) |
88
|
|
|
|
|
|
|
(?: \. [0-9]* )? |
89
|
|
|
|
|
|
|
(?: [eE] [\-\+]? [0-9]+ )? |
90
|
|
|
|
|
|
|
)$/x ? ($_ + 0) : |
91
|
|
|
|
|
|
|
"$_" |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |