line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2012 Jeffrey Kegler |
2
|
|
|
|
|
|
|
# This file is part of Marpa::PP. Marpa::PP is free software: you can |
3
|
|
|
|
|
|
|
# redistribute it and/or modify it under the terms of the GNU Lesser |
4
|
|
|
|
|
|
|
# General Public License as published by the Free Software Foundation, |
5
|
|
|
|
|
|
|
# either version 3 of the License, or (at your option) any later version. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Marpa::PP is distributed in the hope that it will be useful, |
8
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
10
|
|
|
|
|
|
|
# Lesser General Public License for more details. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser |
13
|
|
|
|
|
|
|
# General Public License along with Marpa::PP. If not, see |
14
|
|
|
|
|
|
|
# http://www.gnu.org/licenses/. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Marpa::PP::Internal; |
17
|
|
|
|
|
|
|
|
18
|
44
|
|
|
44
|
|
1144
|
use 5.010; |
|
44
|
|
|
|
|
151
|
|
|
44
|
|
|
|
|
3270
|
|
19
|
44
|
|
|
44
|
|
318
|
use strict; |
|
44
|
|
|
|
|
84
|
|
|
44
|
|
|
|
|
1697
|
|
20
|
44
|
|
|
44
|
|
239
|
use warnings; |
|
44
|
|
|
|
|
214
|
|
|
44
|
|
|
|
|
1634
|
|
21
|
44
|
|
|
44
|
|
55452
|
use integer; |
|
44
|
|
|
|
|
479
|
|
|
44
|
|
|
|
|
245
|
|
22
|
44
|
|
|
44
|
|
1256
|
use Carp; |
|
44
|
|
|
|
|
86
|
|
|
44
|
|
|
|
|
4811
|
|
23
|
|
|
|
|
|
|
|
24
|
44
|
|
|
44
|
|
274
|
use vars qw($VERSION $STRING_VERSION); |
|
44
|
|
|
|
|
87
|
|
|
44
|
|
|
|
|
6939
|
|
25
|
|
|
|
|
|
|
$VERSION = '0.014000'; |
26
|
|
|
|
|
|
|
$STRING_VERSION = $VERSION; |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
## no critic (BuiltinFunctions::ProhibitStringyEval) |
29
|
|
|
|
|
|
|
## no critic (ValuesAndExpressions::RequireConstantVersion) |
30
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
*Marpa::PP::exception = \&Carp::croak; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub Marpa::PP::internal_error { |
36
|
0
|
|
|
0
|
0
|
0
|
Carp::confess( |
37
|
|
|
|
|
|
|
"Internal Marpa::PP Error: This could be a bug in Marpa::PP\n", @_ ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Perl critic at present is not smart about underscores |
41
|
|
|
|
|
|
|
# in hex numbers |
42
|
|
|
|
|
|
|
## no critic (ValuesAndExpressions::RequireNumberSeparators) |
43
|
44
|
|
|
44
|
|
260
|
use constant N_FORMAT_MASK => 0xffff_ffff; |
|
44
|
|
|
|
|
103
|
|
|
44
|
|
|
|
|
4367
|
|
44
|
44
|
|
|
44
|
|
282
|
use constant N_FORMAT_HIGH_BIT => 0x8000_0000; |
|
44
|
|
|
|
|
91
|
|
|
44
|
|
|
|
|
2558
|
|
45
|
|
|
|
|
|
|
## use critic |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Also used as mask, so must be 2**n-1 |
48
|
|
|
|
|
|
|
# Perl critic at present is not smart about underscores |
49
|
|
|
|
|
|
|
# in hex numbers |
50
|
44
|
|
|
44
|
|
246
|
use constant N_FORMAT_MAX => 0x7fff_ffff; |
|
44
|
|
|
|
|
81
|
|
|
44
|
|
|
|
|
8377
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub Marpa::PP::offset { |
53
|
792
|
|
|
792
|
0
|
1992
|
my (@desc) = @_; |
54
|
792
|
|
|
|
|
1392
|
my @fields = (); |
55
|
792
|
|
|
|
|
1652
|
for my $desc (@desc) { push @fields, split q{ }, $desc; } |
|
792
|
|
|
|
|
42241
|
|
56
|
792
|
|
|
|
|
2944
|
my $pkg = caller; |
57
|
792
|
|
|
|
|
1733
|
my $prefix = $pkg . q{::}; |
58
|
792
|
|
|
|
|
1120
|
my $offset = -1; |
59
|
792
|
|
|
|
|
1128
|
my $in_comment = 0; |
60
|
|
|
|
|
|
|
|
61
|
44
|
|
|
44
|
|
360
|
no strict 'refs'; |
|
44
|
|
|
|
|
168
|
|
|
44
|
|
|
|
|
19182
|
|
62
|
792
|
|
|
|
|
1515
|
FIELD: for my $field (@fields) { |
63
|
|
|
|
|
|
|
|
64
|
50512
|
100
|
|
|
|
108119
|
if ($in_comment) { |
65
|
36432
|
|
100
|
|
|
141392
|
$in_comment = $field ne ':}' && $field ne '}'; |
66
|
36432
|
|
|
|
|
61993
|
next FIELD; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
PROCESS_OPTION: { |
70
|
14080
|
100
|
|
|
|
15417
|
last PROCESS_OPTION if $field !~ /\A [{:] /xms; |
|
14080
|
|
|
|
|
62922
|
|
71
|
5280
|
100
|
|
|
|
13132
|
if ( $field =~ / \A [:] package [=] (.*) /xms ) { |
72
|
792
|
|
|
|
|
2326
|
$prefix = $1 . q{::}; |
73
|
792
|
|
|
|
|
2100
|
next FIELD; |
74
|
|
|
|
|
|
|
} |
75
|
4488
|
50
|
|
|
|
18081
|
if ( $field =~ / \A [:]? [{] /xms ) { |
76
|
4488
|
|
|
|
|
5269
|
$in_comment++; |
77
|
4488
|
|
|
|
|
11426
|
next FIELD; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} ## end PROCESS_OPTION: |
80
|
|
|
|
|
|
|
|
81
|
8800
|
100
|
|
|
|
27466
|
if ( $field !~ s/\A=//xms ) { |
82
|
8008
|
|
|
|
|
10837
|
$offset++; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
8800
|
50
|
|
|
|
30569
|
if ( $field =~ / \A ( [^=]* ) = ( [0-9+-]* ) \z/xms ) { |
86
|
0
|
|
|
|
|
0
|
$field = $1; |
87
|
0
|
|
|
|
|
0
|
$offset = $2 + 0; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
8800
|
50
|
|
|
|
30132
|
Marpa::PP::exception("Unacceptable field name: $field") |
91
|
|
|
|
|
|
|
if $field =~ /[^A-Z0-9_]/xms; |
92
|
8800
|
|
|
|
|
17153
|
my $field_name = $prefix . $field; |
93
|
8800
|
|
|
0
|
|
87711
|
*{$field_name} = sub () {$offset}; |
|
8800
|
|
|
|
|
116673
|
|
|
0
|
|
|
|
|
0
|
|
94
|
|
|
|
|
|
|
} ## end for my $field (@fields) |
95
|
792
|
|
|
|
|
470239
|
return 1; |
96
|
|
|
|
|
|
|
} ## end sub Marpa::PP::offset |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |