GraphQL/Language/Parser.pm

filter: Statementstmt 100% 61 / 61 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod 100% 2 / 2 totaltotal 93.2% 83 / 89 CC 7 SCAR 8.7
CC
7
Cov
92%
parse
5.3
format_error
3.0
BEGIN
1.0
CRAP 2.4
« GraphQL/Role/Named.pm ↑ Summary GraphQL/Plugin/Type/DateTime.pm »
1 package GraphQL::Language::Parser;
2  
3 21 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 21 ▶use base qw(Pegex::Parser);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 21 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 21 ▶use Types::Standard -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 21 ▶use GraphQL::MaybeTypeCheck;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 21 ▶use GraphQL::Language::Grammar;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 21 ▶use GraphQL::Language::Receiver;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 21 ▶use GraphQL::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 21 our $VERSION = '0.02';
15 21 our @EXPORT_OK = qw(
16 parse
17 );
18  
19 =head1 NAME
20  
21 GraphQL::Language::Parser - GraphQL Pegex parser
22  
23 =head1 SYNOPSIS
24  
25 use GraphQL::Language::Parser qw(parse);
26 my $parsed = parse(
27 $source
28 );
29  
30 =head1 DESCRIPTION
31  
32 Provides both an outside-accessible point of entry into the GraphQL
33 parser (see above), and a subclass of L<Pegex::Parser> to parse a document
34 into an AST usable by GraphQL.
35  
36 =head1 METHODS
37  
38 =head2 parse
39  
40 parse($source, $noLocation);
41  
42 B<NB> that unlike in C<Pegex::Parser> this is a function, not an instance
43 method. This achieves hiding of Pegex implementation details.
44  
45 =cut
46  
47 21 my $GRAMMAR = GraphQL::Language::Grammar->new; # singleton
48 359 ▶fun parse(
Subroutine parse: called CC=5 SCAR=16.7
Pod documented
49 Str $source,
50 Bool $noLocation = undef,
51 359 ▶) :ReturnType(ArrayRef[HashRef]) {
Branch: 4 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for fun parse (expected 1, got ' . @_ . ')') 0 359 359
@_ > 2 and Function::Parameters::_croak('Too many arguments for fun parse (expected 2, got ' . @_ . ')') 0 359 359
Type::Tiny::XS::Str($source) or Function::Parameters::_croak('In fun parse: parameter 1 ($source): ' . ${my $v = bless( {"_is_core" => 1,"_overload_coderef" => sub { package Sub::Defer; use warnings; use strict; $undeferred ||= undefer_sub($deferred_info->[4]); goto \&$undeferred;},"_overload_coderef_no_rebuild" => 1,"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Str","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; ref \$_ eq 'SCALAR' or ref \(my $val = $_) eq 'SCALAR';},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 291,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Str","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; use warnings; use strict; $Type::Tiny::AvoidCallbacks ? goto $orig_inlined : "$xsubname($_[1])";},"library" => "Types::Standard","name" => "Str","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; defined $_[0] and not ref $_[0] or _failed_check(8, 'Value', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Value","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; not ref $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 276,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Value","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "defined($_[1]) and not ref($_[1])";},"library" => "Types::Standard","name" => "Value","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; defined $_[0] or _failed_check(7, 'Defined', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Defined","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; defined $_[0] and _failed_check(6, 'Undef', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Undef","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => {},"constraint" => sub { package Types::Standard; no warnings; use strict; not defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 254,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Undef","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "!defined($_[1])";},"library" => "Types::Standard","name" => "Undef","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Item","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 226,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Item","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Item","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Sub::Defer; use warnings; use strict; $undeferred ||= undefer_sub($deferred_info->[4]); goto \&$undeferred;},"_overload_coderef_no_rebuild" => 1,"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"display_name" => "to_Any","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complement_name" => "None","constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 220,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Any","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Any","type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 1}, 'Type::Tiny' ),"uniq" => 2}, 'Type::Tiny' ),"type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 6}, 'Type::Tiny' ),"constraint" => sub { package Types::Standard; no warnings; use strict; defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 262,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Defined","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "defined($_[1])";},"library" => "Types::Standard","name" => "Defined","parent" => {},"uniq" => 7}, 'Type::Tiny' ),"uniq" => 8}, 'Type::Tiny' ),"sorter" => sub { package Types::Standard; no warnings; use strict; $_[0] cmp $_[1];},"type_default" => sub { package Types::Standard; no warnings; use strict; return '';},"uniq" => 9}, 'Type::Tiny' );$v->{"coercion"}{"type_constraint"} = $v;$v->{"compiled_type_constraint"} = $v->{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"};$v->{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"parent"};$v->{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"complementary_type"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"};$v->{"parent"}{"parent"}{"complementary_type"}{"compiled_type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"complementary_type"}{"complementary_type"} = $v->{"parent"}{"parent"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"constraint"};$v->{"parent"}{"parent"}{"parent"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}; \$v}->get_message($source)) 359 0 359
$noLocation = ${my $v = bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; Type::Tiny::XS::Bool($_[0]) or _failed_check(3, 'Bool', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"compiled_coercion" => sub ($) { package Eval::TypeTiny::Sandbox; use strict; Type::Tiny::XS::Bool($_[0]) ? $_[0] : scalar do { local $_ = $_[0]; not !$_ };},"display_name" => "to_Bool","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [bless( {"_is_core" => 1,"_overload_coderef" => sub { package Sub::Defer; use warnings; use strict; $undeferred ||= undefer_sub($deferred_info->[4]); goto \&$undeferred;},"_overload_coderef_no_rebuild" => 1,"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Any","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complement_name" => "None","constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 220,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Any","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Any","type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 1}, 'Type::Tiny' ),"!!\$_"],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; not ref $_ and !defined($_) || $_ eq '' || $_ eq '0' || $_ eq '1';},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 242,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Bool","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; use warnings; use strict; $Type::Tiny::AvoidCallbacks ? goto $orig_inlined : "$xsubname($_[1])";},"library" => "Types::Standard","name" => "Bool","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"display_name" => "to_Item","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 226,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Item","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Item","parent" => {},"uniq" => 2}, 'Type::Tiny' ),"type_default" => sub { package Types::Standard; no warnings; use strict; return !1;},"uniq" => 3}, 'Type::Tiny' );$v->{"coercion"}{"type_coercion_map"}[0]{"coercion"}{"type_constraint"} = $v->{"coercion"}{"type_coercion_map"}[0];$v->{"coercion"}{"type_coercion_map"}[0]{"compiled_type_constraint"} = $v->{"coercion"}{"type_coercion_map"}[0]{"coercion"}{"_compiled_type_constraint_check"};$v->{"coercion"}{"type_constraint"} = $v;$v->{"compiled_type_constraint"} = $v->{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"coercion"}{"type_coercion_map"}[0]{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"};$v->{"parent"}{"compiled_type_constraint"} = $v->{"coercion"}{"type_coercion_map"}[0]{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"constraint"} = $v->{"coercion"}{"type_coercion_map"}[0]{"constraint"};$v->{"parent"}{"parent"} = $v->{"coercion"}{"type_coercion_map"}[0]; \$v}->coerce($noLocation), Type::Tiny::XS::Bool($noLocation) or Function::Parameters::_croak('In fun parse: parameter 2 ($noLocation): ' . ${my $v = bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; Type::Tiny::XS::Bool($_[0]) or _failed_check(3, 'Bool', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"compiled_coercion" => sub ($) { package Eval::TypeTiny::Sandbox; use strict; Type::Tiny::XS::Bool($_[0]) ? $_[0] : scalar do { local $_ = $_[0]; not !$_ };},"display_name" => "to_Bool","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [bless( {"_is_core" => 1,"_overload_coderef" => sub { package Sub::Defer; use warnings; use strict; $undeferred ||= undefer_sub($deferred_info->[4]); goto \&$undeferred;},"_overload_coderef_no_rebuild" => 1,"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Any","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complement_name" => "None","constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 220,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Any","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Any","type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 1}, 'Type::Tiny' ),"!!\$_"],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; not ref $_ and !defined($_) || $_ eq '' || $_ eq '0' || $_ eq '1';},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 242,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Bool","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; use warnings; use strict; $Type::Tiny::AvoidCallbacks ? goto $orig_inlined : "$xsubname($_[1])";},"library" => "Types::Standard","name" => "Bool","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"display_name" => "to_Item","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 226,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Item","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Item","parent" => {},"uniq" => 2}, 'Type::Tiny' ),"type_default" => sub { package Types::Standard; no warnings; use strict; return !1;},"uniq" => 3}, 'Type::Tiny' );$v->{"coercion"}{"type_coercion_map"}[0]{"coercion"}{"type_constraint"} = $v->{"coercion"}{"type_coercion_map"}[0];$v->{"coercion"}{"type_coercion_map"}[0]{"compiled_type_constraint"} = $v->{"coercion"}{"type_coercion_map"}[0]{"coercion"}{"_compiled_type_constraint_check"};$v->{"coercion"}{"type_constraint"} = $v;$v->{"compiled_type_constraint"} = $v->{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"coercion"}{"type_coercion_map"}[0]{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"};$v->{"parent"}{"compiled_type_constraint"} = $v->{"coercion"}{"type_coercion_map"}[0]{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"constraint"} = $v->{"coercion"}{"type_coercion_map"}[0]{"constraint"};$v->{"parent"}{"parent"} = $v->{"coercion"}{"type_coercion_map"}[0]; \$v}->get_message($noLocation)) 359 0 359
52 359 my $parser = __PACKAGE__->SUPER::new(
53 grammar => $GRAMMAR,
54 receiver => GraphQL::Language::Receiver->new,
55 );
56 359 my $input = Pegex::Input->new(string => $source);
57 359 scalar $parser->SUPER::parse($input);
58 21 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
59  
60 =head2 format_error
61  
62 Override of parent method. Returns a L<GraphQL::Error>.
63  
64 =cut
65  
66 35 ▶sub format_error :ReturnType(InstanceOf['GraphQL::Error']) {
Subroutine format_error: called CC=3 SCAR=11.0
Pod documented
67 35 my ($self, $msg) = @_;
68 35 my $buffer = $self->{buffer};
69 35 my $position = $self->{farthest};
70 35 my $real_pos = $self->{position};
71 35 my ($line, $column) = @{$self->line_column($position)};
72 35 ▶ my $pretext = substr(
Branch: 2 branches
BranchTrueFalseTotal
$position < 50 ? : 35 0 35
$position < 50 ? : 35 0 35
73 $$buffer,
74 $position < 50 ? 0 : $position - 50,
75 $position < 50 ? $position : 50
76 );
77 35 my $context = substr($$buffer, $position, 50);
78 35 $pretext =~ s/.*\n//gs;
79 35 $context =~ s/\n/\\n/g;
80 35 return GraphQL::Error->new(
81 locations => [ { line => $line, column => $column } ],
82 message => <<EOF);
83 Error parsing Pegex document:
84 msg: $msg
85 context: $pretext$context
86 35 ${\ (' ' x (length($pretext)) . '^')}
87 position: $position ($real_pos pre-lookahead)
88 EOF
89 21 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
90  
91 21 1;
« GraphQL/Role/Named.pm ↑ Summary GraphQL/Plugin/Type/DateTime.pm »