| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Marpa::R3 is Copyright (C) 2018, Jeffrey Kegler. |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# This module is free software; you can redistribute it and/or modify it |
|
4
|
|
|
|
|
|
|
# under the same terms as Perl 5.10.1. For more details, see the full text |
|
5
|
|
|
|
|
|
|
# of the licenses in the directory LICENSES. |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be |
|
8
|
|
|
|
|
|
|
# useful, but it is provided "as is" and without any express |
|
9
|
|
|
|
|
|
|
# or implied warranties. For details, see the full text of |
|
10
|
|
|
|
|
|
|
# of the licenses in the directory LICENSES. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Marpa::R3 exceptions and their methods |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Adapted from CPAN's Exception::Class module |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Marpa::R3::X; |
|
17
|
|
|
|
|
|
|
|
|
18
|
104
|
|
|
104
|
|
2858
|
use 5.010001; |
|
|
104
|
|
|
|
|
345
|
|
|
19
|
104
|
|
|
104
|
|
519
|
use warnings; |
|
|
104
|
|
|
|
|
201
|
|
|
|
104
|
|
|
|
|
2782
|
|
|
20
|
104
|
|
|
104
|
|
505
|
use strict; |
|
|
104
|
|
|
|
|
193
|
|
|
|
104
|
|
|
|
|
2446
|
|
|
21
|
104
|
|
|
104
|
|
479
|
use English qw( -no_match_vars ); |
|
|
104
|
|
|
|
|
201
|
|
|
|
104
|
|
|
|
|
695
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
104
|
|
|
104
|
|
35293
|
use vars qw($VERSION $STRING_VERSION); |
|
|
104
|
|
|
|
|
229
|
|
|
|
104
|
|
|
|
|
8091
|
|
|
24
|
|
|
|
|
|
|
$VERSION = '4.001_054'; |
|
25
|
|
|
|
|
|
|
$STRING_VERSION = $VERSION; |
|
26
|
|
|
|
|
|
|
## no critic(BuiltinFunctions::ProhibitStringyEval) |
|
27
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
28
|
|
|
|
|
|
|
## use critic |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
package Marpa::R3::Internal::X; |
|
31
|
|
|
|
|
|
|
|
|
32
|
104
|
|
|
104
|
|
645
|
use warnings; |
|
|
104
|
|
|
|
|
207
|
|
|
|
104
|
|
|
|
|
3058
|
|
|
33
|
104
|
|
|
104
|
|
580
|
use strict; |
|
|
104
|
|
|
|
|
199
|
|
|
|
104
|
|
|
|
|
2484
|
|
|
34
|
104
|
|
|
104
|
|
498
|
use English qw( -no_match_vars ); |
|
|
104
|
|
|
|
|
223
|
|
|
|
104
|
|
|
|
|
571
|
|
|
35
|
104
|
|
|
104
|
|
30216
|
use Scalar::Util qw( blessed ); |
|
|
104
|
|
|
|
|
205
|
|
|
|
104
|
|
|
|
|
6685
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
use overload |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# an exception is always true |
|
40
|
104
|
|
|
104
|
|
104527
|
bool => sub {1}, '""' => 'as_string', fallback => 1; |
|
|
104
|
|
|
0
|
|
84981
|
|
|
|
104
|
|
|
|
|
793
|
|
|
|
0
|
|
|
|
|
0
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Create accessor routines |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub throw { |
|
45
|
3
|
|
|
3
|
|
6
|
my $proto = shift; |
|
46
|
3
|
50
|
|
|
|
16
|
$proto->rethrow if ref $proto; |
|
47
|
0
|
|
|
|
|
0
|
die $proto->new(@_); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub rethrow { |
|
51
|
3
|
|
|
3
|
|
6
|
my $self = shift; |
|
52
|
3
|
|
|
|
|
22
|
die $self; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub new { |
|
56
|
3
|
|
|
3
|
|
10
|
my ($class, $args) = @_; |
|
57
|
3
|
|
50
|
|
|
7
|
$args //= { error => $_[0] }; |
|
58
|
3
|
|
|
|
|
15
|
return bless $args, $class; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub description { |
|
62
|
0
|
|
|
0
|
|
0
|
return 'Generic exception'; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub as_string { |
|
66
|
3
|
|
|
3
|
|
7
|
my $self = shift; |
|
67
|
3
|
|
|
|
|
5
|
my $string = q{}; |
|
68
|
3
|
|
|
|
|
8
|
my $to_string = $self->{to_string}; |
|
69
|
3
|
50
|
33
|
|
|
16
|
if ( $to_string and ref $to_string eq 'CODE' ) { |
|
70
|
3
|
|
|
|
|
5
|
$string = &{$to_string}($self); |
|
|
3
|
|
|
|
|
10
|
|
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
else { |
|
73
|
0
|
|
|
|
|
0
|
FIELD: for my $field ( sort keys %{$self} ) { |
|
|
0
|
|
|
|
|
0
|
|
|
74
|
0
|
0
|
|
|
|
0
|
if ( $field eq 'try' ) { |
|
75
|
0
|
|
|
|
|
0
|
my $try_to_string = $self->{try}; |
|
76
|
0
|
0
|
|
|
|
0
|
if ( ref $try_to_string ne 'CODE' ) { |
|
77
|
0
|
|
|
|
|
0
|
$string .= qq{$field: [!not a CODE object!]\n}; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
0
|
|
|
|
|
0
|
$string .= &{$try_to_string}($self); |
|
|
0
|
|
|
|
|
0
|
|
|
80
|
0
|
|
|
|
|
0
|
next FIELD; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
0
|
0
|
|
|
|
0
|
next FIELD if $field =~ /\A (slg|slr|tracer|msg|fatal) \z/; |
|
83
|
0
|
|
|
|
|
0
|
my $value = $self->{$field}; |
|
84
|
0
|
0
|
|
|
|
0
|
if ( not defined $value ) { |
|
85
|
0
|
|
|
|
|
0
|
$string .= "$field: [not defined]\n"; |
|
86
|
0
|
|
|
|
|
0
|
next FIELD; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
0
|
|
|
|
|
0
|
my $ref_type = ref $value; |
|
89
|
0
|
0
|
|
|
|
0
|
if ($ref_type) { |
|
90
|
0
|
|
|
|
|
0
|
$string .= "$field: ref to $ref_type\n"; |
|
91
|
0
|
|
|
|
|
0
|
next FIELD; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
0
|
|
|
|
|
0
|
$string .= "$field: $value\n"; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
3
|
|
50
|
|
|
18
|
my $fatal = $self->{fatal} // 1; |
|
97
|
3
|
50
|
|
|
|
7
|
if ($fatal) { |
|
98
|
3
|
|
|
|
|
9
|
$string = |
|
99
|
|
|
|
|
|
|
qq{========= Marpa::R3 Fatal error =========\n} |
|
100
|
|
|
|
|
|
|
. $string |
|
101
|
|
|
|
|
|
|
. qq{=========================================\n}; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
3
|
|
|
|
|
11
|
return $string; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub caught { |
|
107
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
108
|
0
|
|
|
|
|
|
my $e = $@; |
|
109
|
0
|
0
|
0
|
|
|
|
return unless defined $e && blessed($e) && $e->isa($class); |
|
|
|
|
0
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
return $e; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |