line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::Transform::Parser; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
90440
|
use strict; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
63
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
53
|
|
5
|
2
|
|
|
2
|
|
11
|
use base qw(Pegex::Parser); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
941
|
|
6
|
2
|
|
|
2
|
|
24435
|
use Exporter 'import'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
58
|
|
7
|
2
|
|
|
2
|
|
979
|
use JSON::Transform::Grammar; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
15
|
|
8
|
2
|
|
|
2
|
|
892
|
use XML::Invisible::Receiver; |
|
2
|
|
|
|
|
4498
|
|
|
2
|
|
|
|
|
74
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
13
|
use constant DEBUG => $ENV{JSON_TRANSFORM_DEBUG}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
311
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
13
|
|
|
|
|
|
|
parse |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
JSON::Transform::Parser - JSON::Transform Pegex parser |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use JSON::Transform::Parser qw(parse); |
23
|
|
|
|
|
|
|
my $parsed = parse( |
24
|
|
|
|
|
|
|
$source |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Provides both an outside-accessible point of entry into the JSON::Transform |
30
|
|
|
|
|
|
|
parser (see above), and a subclass of L to parse a document |
31
|
|
|
|
|
|
|
into an AST usable by JSON::Transform. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 METHODS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 parse |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
parse($source); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
B that unlike in C this is a function, not an instance |
40
|
|
|
|
|
|
|
method. This achieves hiding of Pegex implementation details. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $GRAMMAR = JSON::Transform::Grammar->new; # singleton |
45
|
|
|
|
|
|
|
sub parse { |
46
|
24
|
|
|
24
|
1
|
51311
|
my ($source) = @_; |
47
|
24
|
|
|
|
|
126
|
my $parser = __PACKAGE__->SUPER::new( |
48
|
|
|
|
|
|
|
grammar => $GRAMMAR, |
49
|
|
|
|
|
|
|
receiver => XML::Invisible::Receiver->new, |
50
|
|
|
|
|
|
|
debug => DEBUG, |
51
|
|
|
|
|
|
|
); |
52
|
24
|
|
|
|
|
2807
|
my $input = Pegex::Input->new(string => $source); |
53
|
24
|
|
|
|
|
1075
|
scalar $parser->SUPER::parse($input); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |