line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
2
|
|
|
|
|
|
|
package RPerl::DataStructure::Hash::Entry; |
3
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
106
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
92
|
|
5
|
4
|
|
|
4
|
|
22
|
use RPerl::AfterSubclass; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
508
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.002_600; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
9
|
4
|
|
|
4
|
|
31
|
use parent qw(RPerl::GrammarRule); |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
26
|
|
10
|
4
|
|
|
4
|
|
275
|
use RPerl::GrammarRule; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
3663
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# [[[ CRITICS ]]] |
13
|
|
|
|
|
|
|
## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator |
14
|
|
|
|
|
|
|
## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# [[[ OO PROPERTIES ]]] |
17
|
|
|
|
|
|
|
our hashref $properties = {}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# [[[ SUBROUTINES & OO METHODS ]]] |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our string_hashref::method $ast_to_rperl__generate = sub { |
22
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
23
|
|
|
|
|
|
|
my string_hashref $rperl_source_group = { PMC => q{} }; |
24
|
|
|
|
|
|
|
my string_hashref $rperl_source_subgroup; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# RPerl::diag( 'in Hash::Entry->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my string $self_class = ref $self; |
29
|
|
|
|
|
|
|
if ( $self_class eq 'HashEntry_204' ) { # HashEntry -> VarOrLitOrOpStrOrWord OP20_HASH_FATARROW OPTIONAL-48 SubExpression |
30
|
|
|
|
|
|
|
my string $key = $self->{children}->[0]; |
31
|
|
|
|
|
|
|
my string $key_class = ref $key; |
32
|
|
|
|
|
|
|
my string $fat_arrow = $self->{children}->[1]; |
33
|
|
|
|
|
|
|
my object $type_inner_optional = $self->{children}->[2]; |
34
|
|
|
|
|
|
|
my string $key_name = undef; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
if ( ( $key_class eq 'VarOrLitOrOpStrOrWord_229' ) |
37
|
|
|
|
|
|
|
or ( $key_class eq 'VarOrLitOrOpStrOrWord_230' ) ) |
38
|
|
|
|
|
|
|
{ # Variable or Literal |
39
|
|
|
|
|
|
|
$rperl_source_subgroup = $key->ast_to_rperl__generate($modes); |
40
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ( $key_class eq 'VarOrLitOrOpStrOrWord_231' ) { # OpStringOrWord |
43
|
|
|
|
|
|
|
$key_name = $key->{children}->[0]->{children}->[0]; |
44
|
|
|
|
|
|
|
$key_name =~ s/^(\w+)\s*$/$1/gxms; # strip trailing whitespace, caused by grammar matching operator names with trailing spaces |
45
|
|
|
|
|
|
|
if ($key_name !~ /^[a-z]/) { |
46
|
|
|
|
|
|
|
die 'ERROR ECOGEASRP23, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: invalid hash key ' . q{'} |
47
|
|
|
|
|
|
|
. $key_name . q{'} |
48
|
|
|
|
|
|
|
. ' does not start with a lowercase letter a-z, dying' . "\n"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
$rperl_source_group->{PMC} .= $key_name . q{ }; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
else { |
53
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( q{ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '} |
54
|
|
|
|
|
|
|
. ($key_class) |
55
|
|
|
|
|
|
|
. q{' found where VarOrLitOrOpStrOrWord_229, VarOrLitOrOpStrOrWord_230, or VarOrLitOrOpStrOrWord_231 expected, dying} ) |
56
|
|
|
|
|
|
|
. "\n"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
if ( ( exists $type_inner_optional->{children}->[0] ) and ( defined $key_name ) ) { |
60
|
|
|
|
|
|
|
my string $type_inner_name = $type_inner_optional->{children}->[0]->{children}->[3]->{children}->[0]; |
61
|
|
|
|
|
|
|
$type_inner_name =~ s/^(\w+)\s*$/$1/gxms; # strip trailing whitespace, caused by grammar matching operator names with trailing spaces |
62
|
|
|
|
|
|
|
if ( $type_inner_name !~ /$key_name$/xms ) { |
63
|
|
|
|
|
|
|
die 'ERROR ECOGEASRP22, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: redundant name mismatch, inner type name ' . q{'} |
64
|
|
|
|
|
|
|
. $type_inner_name . q{'} |
65
|
|
|
|
|
|
|
. ' does not end with OO properties or hash key ' . q{'} |
66
|
|
|
|
|
|
|
. $key_name . q{'} |
67
|
|
|
|
|
|
|
. ', dying' . "\n"; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$rperl_source_group->{PMC} .= $fat_arrow . q{ }; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
if ( exists $type_inner_optional->{children}->[0] ) { |
74
|
|
|
|
|
|
|
$rperl_source_subgroup = $type_inner_optional->{children}->[0]->ast_to_rperl__generate($modes); |
75
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my object $subexpression = $self->{children}->[3]; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$rperl_source_subgroup = $subexpression->ast_to_rperl__generate($modes); |
81
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
elsif ( $self_class eq 'HashEntry_206' ) { # HashEntry -> ENV |
84
|
|
|
|
|
|
|
my string $env = $self->{children}->[0]; |
85
|
|
|
|
|
|
|
$rperl_source_group->{PMC} .= $env . "\n"; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' |
89
|
|
|
|
|
|
|
. $self_class |
90
|
|
|
|
|
|
|
. ' found where HashEntry_204 or HashEntry_206 expected, dying' ) |
91
|
|
|
|
|
|
|
. "\n"; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
return $rperl_source_group; |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub { |
98
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
99
|
|
|
|
|
|
|
my string_hashref $cpp_source_group = { CPP => q{// <<< RP::DS::H::E __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" }; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
#... |
102
|
|
|
|
|
|
|
return $cpp_source_group; |
103
|
|
|
|
|
|
|
}; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
our string_hashref::method $ast_to_cpp__generate__CPPOPS_CPPTYPES = sub { |
106
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
107
|
|
|
|
|
|
|
my string_hashref $cpp_source_group = { CPP => q{} }; |
108
|
|
|
|
|
|
|
my string_hashref $cpp_source_subgroup; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# RPerl::diag( 'in Hash::Entry->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my string $self_class = ref $self; |
113
|
|
|
|
|
|
|
if ( $self_class eq 'HashEntry_204' ) { # HashEntry -> VarOrLitOrOpStrOrWord OP20_HASH_FATARROW OPTIONAL-48 SubExpression |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my string $key = $self->{children}->[0]; |
116
|
|
|
|
|
|
|
my string $key_class = ref $key; |
117
|
|
|
|
|
|
|
my object $type_inner_optional = $self->{children}->[2]; |
118
|
|
|
|
|
|
|
my string $key_name = undef; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= '{'; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
if ( ( $key_class eq 'VarOrLitOrOpStrOrWord_229' ) |
123
|
|
|
|
|
|
|
or ( $key_class eq 'VarOrLitOrOpStrOrWord_230' ) ) |
124
|
|
|
|
|
|
|
{ # Variable or Literal |
125
|
|
|
|
|
|
|
$cpp_source_subgroup = $key->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); |
126
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
elsif ( $key_class eq 'VarOrLitOrOpStrOrWord_231' ) { # OpStringOrWord |
129
|
|
|
|
|
|
|
$key_name = $key->{children}->[0]->{children}->[0]; |
130
|
|
|
|
|
|
|
$key_name =~ s/^(\w+)\s*$/$1/gxms; # strip trailing whitespace, caused by grammar matching operator names with trailing spaces |
131
|
|
|
|
|
|
|
if ($key_name !~ /^[a-z]/) { |
132
|
|
|
|
|
|
|
die 'ERROR ECOGEASCP23, CODE GENERATOR, ABSTRACT SYNTAX TO C++: invalid hash key ' . q{'} |
133
|
|
|
|
|
|
|
. $key_name . q{'} |
134
|
|
|
|
|
|
|
. ' does not start with a lowercase letter a-z, dying' . "\n"; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= q{"} . $key_name . q{" }; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
else { |
139
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( q{ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '} |
140
|
|
|
|
|
|
|
. ($key_class) |
141
|
|
|
|
|
|
|
. q{' found where VarOrLitOrOpStrOrWord_229, VarOrLitOrOpStrOrWord_230, or VarOrLitOrOpStrOrWord_231 expected, dying} ) |
142
|
|
|
|
|
|
|
. "\n"; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
if ( ( exists $type_inner_optional->{children}->[0] ) and ( defined $key_name ) ) { |
146
|
|
|
|
|
|
|
my string $type_inner_name = $type_inner_optional->{children}->[0]->{children}->[3]->{children}->[0]; |
147
|
|
|
|
|
|
|
$type_inner_name =~ s/^(\w+)\s*$/$1/gxms; # strip trailing whitespace, caused by grammar matching operator names with trailing spaces |
148
|
|
|
|
|
|
|
if ( $type_inner_name !~ /$key_name$/xms ) { |
149
|
|
|
|
|
|
|
die 'ERROR ECOGEASCP22, CODE GENERATOR, ABSTRACT SYNTAX TO C++: redundant name mismatch, inner type name ' . q{'} |
150
|
|
|
|
|
|
|
. $type_inner_name . q{'} |
151
|
|
|
|
|
|
|
. ' does not end with OO properties or hash key ' . q{'} |
152
|
|
|
|
|
|
|
. $key_name . q{'} |
153
|
|
|
|
|
|
|
. ', dying' . "\n"; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= q{, }; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my object $subexpression = $self->{children}->[3]; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
$cpp_source_subgroup = $subexpression->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); |
162
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= '}'; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
elsif ( $self_class eq 'HashEntry_206' ) { # HashEntry -> ENV |
167
|
|
|
|
|
|
|
my string $env = $self->{children}->[0]; |
168
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= q{// <<< RP::DS::H::E __DUMMY_SOURCE_CODE CPPOPS_CPPTYPES >>>} . "\n"; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
else { |
171
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' |
172
|
|
|
|
|
|
|
. $self_class |
173
|
|
|
|
|
|
|
. ' found where HashEntry_204 or HashEntry_206 expected, dying' ) |
174
|
|
|
|
|
|
|
. "\n"; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
return $cpp_source_group; |
178
|
|
|
|
|
|
|
}; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; # end of class |