| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.014; |
|
3
|
21
|
|
|
21
|
|
102475
|
use strict; |
|
|
21
|
|
|
|
|
80
|
|
|
4
|
21
|
|
|
21
|
|
104
|
use warnings; |
|
|
650
|
|
|
|
|
7371
|
|
|
|
469
|
|
|
|
|
4663
|
|
|
5
|
380
|
|
|
21
|
|
45689
|
use base qw(Pegex::Parser); |
|
|
380
|
|
|
|
|
15515
|
|
|
|
21
|
|
|
|
|
629
|
|
|
6
|
21
|
|
|
21
|
|
123
|
use Exporter 'import'; |
|
|
21
|
|
|
|
|
115
|
|
|
|
21
|
|
|
|
|
9266
|
|
|
7
|
21
|
|
|
21
|
|
231854
|
use Types::Standard -all; |
|
|
21
|
|
|
|
|
51
|
|
|
|
21
|
|
|
|
|
713
|
|
|
8
|
21
|
|
|
21
|
|
603
|
use GraphQL::MaybeTypeCheck; |
|
|
21
|
|
|
|
|
65550
|
|
|
|
21
|
|
|
|
|
210
|
|
|
9
|
21
|
|
|
21
|
|
846984
|
use GraphQL::Language::Grammar; |
|
|
21
|
|
|
|
|
62
|
|
|
|
21
|
|
|
|
|
217
|
|
|
10
|
21
|
|
|
21
|
|
13714
|
use GraphQL::Language::Receiver; |
|
|
21
|
|
|
|
|
61
|
|
|
|
21
|
|
|
|
|
241
|
|
|
11
|
21
|
|
|
21
|
|
10576
|
use GraphQL::Error; |
|
|
21
|
|
|
|
|
69
|
|
|
|
21
|
|
|
|
|
287
|
|
|
12
|
21
|
|
|
21
|
|
9470
|
|
|
|
21
|
|
|
|
|
80
|
|
|
|
21
|
|
|
|
|
172
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
|
15
|
|
|
|
|
|
|
parse |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
GraphQL::Language::Parser - GraphQL Pegex parser |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use GraphQL::Language::Parser qw(parse); |
|
25
|
|
|
|
|
|
|
my $parsed = parse( |
|
26
|
|
|
|
|
|
|
$source |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Provides both an outside-accessible point of entry into the GraphQL |
|
32
|
|
|
|
|
|
|
parser (see above), and a subclass of L<Pegex::Parser> to parse a document |
|
33
|
|
|
|
|
|
|
into an AST usable by GraphQL. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 METHODS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 parse |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
parse($source, $noLocation); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
B<NB> that unlike in C<Pegex::Parser> this is a function, not an instance |
|
42
|
|
|
|
|
|
|
method. This achieves hiding of Pegex implementation details. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $GRAMMAR = GraphQL::Language::Grammar->new; # singleton |
|
47
|
|
|
|
|
|
|
fun parse( |
|
48
|
|
|
|
|
|
|
Str $source, |
|
49
|
|
|
|
|
|
|
Bool $noLocation = undef, |
|
50
|
|
|
|
|
|
|
) :ReturnType(ArrayRef[HashRef]) { |
|
51
|
359
|
50
|
|
359
|
1
|
272726
|
my $parser = __PACKAGE__->SUPER::new( |
|
|
359
|
50
|
|
|
|
1078
|
|
|
|
359
|
100
|
|
|
|
868
|
|
|
|
359
|
50
|
|
|
|
1362
|
|
|
|
21
|
|
|
|
|
10903
|
|
|
|
21
|
|
|
|
|
65
|
|
|
52
|
21
|
|
|
|
|
100
|
grammar => $GRAMMAR, |
|
53
|
|
|
|
|
|
|
receiver => GraphQL::Language::Receiver->new, |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
my $input = Pegex::Input->new(string => $source); |
|
56
|
35
|
|
|
|
|
32357
|
scalar $parser->SUPER::parse($input); |
|
57
|
35
|
|
|
|
|
112
|
} |
|
58
|
21
|
|
|
21
|
|
6089
|
|
|
|
21
|
|
|
|
|
43
|
|
|
|
21
|
|
|
|
|
158
|
|
|
59
|
|
|
|
|
|
|
=head2 format_error |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Override of parent method. Returns a L<GraphQL::Error>. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my ($self, $msg) = @_; |
|
66
|
|
|
|
|
|
|
my $buffer = $self->{buffer}; |
|
67
|
35
|
|
|
35
|
1
|
133
|
my $position = $self->{farthest}; |
|
68
|
35
|
|
|
|
|
998
|
my $real_pos = $self->{position}; |
|
69
|
35
|
|
|
|
|
99
|
my ($line, $column) = @{$self->line_column($position)}; |
|
70
|
35
|
|
|
|
|
131
|
my $pretext = substr( |
|
71
|
35
|
|
|
|
|
96
|
$$buffer, |
|
|
35
|
|
|
|
|
291
|
|
|
72
|
35
|
|
|
|
|
1598
|
$position < 50 ? 0 : $position - 50, |
|
73
|
|
|
|
|
|
|
$position < 50 ? $position : 50 |
|
74
|
|
|
|
|
|
|
); |
|
75
|
|
|
|
|
|
|
my $context = substr($$buffer, $position, 50); |
|
76
|
|
|
|
|
|
|
$pretext =~ s/.*\n//gs; |
|
77
|
|
|
|
|
|
|
$context =~ s/\n/\\n/g; |
|
78
|
|
|
|
|
|
|
return GraphQL::Error->new( |
|
79
|
|
|
|
|
|
|
locations => [ { line => $line, column => $column } ], |
|
80
|
|
|
|
|
|
|
message => <<EOF); |
|
81
|
|
|
|
|
|
|
Error parsing Pegex document: |
|
82
|
|
|
|
|
|
|
msg: $msg |
|
83
|
|
|
|
|
|
|
context: $pretext$context |
|
84
|
|
|
|
|
|
|
${\ (' ' x (length($pretext)) . '^')} |
|
85
|
|
|
|
|
|
|
position: $position ($real_pos pre-lookahead) |
|
86
|
|
|
|
|
|
|
EOF |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
35
|
|
|
21
|
|
90
|
1; |
|
|
35
|
|
|
|
|
67
|
|
|
|
35
|
|
|
|
|
82
|
|