line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
2
|
|
|
|
|
|
|
package RPerl::DataStructure::Array::ListElements; |
3
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
109
|
|
4
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
92
|
|
5
|
4
|
|
|
4
|
|
23
|
use RPerl::AfterSubclass; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
483
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.003_000; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
9
|
4
|
|
|
4
|
|
26
|
use parent qw(RPerl::GrammarRule); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
24
|
|
10
|
4
|
|
|
4
|
|
213
|
use RPerl::GrammarRule; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
2526
|
|
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 integer::method $length = sub { |
22
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
23
|
|
|
|
|
|
|
my integer $length = 0; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# RPerl::diag( 'in Array::ListElements->length(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
if ( exists $self->{children}->[0] ) { |
28
|
|
|
|
|
|
|
$length++; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
|
|
|
|
|
|
return $length; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
my object $list_elements_star = $self->{children}->[1]; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
foreach my object $list_element ( @{ $list_elements_star->{children} } ) { |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# RPerl::diag( 'in Array::ListElements->length(), top of foreach() loop, have $list_element = ' . "\n" . RPerl::Parser::rperl_ast__dump($list_element) . "\n" ); |
38
|
|
|
|
|
|
|
if ( ref $list_element ne 'TERMINAL' ) { |
39
|
|
|
|
|
|
|
$length++; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return $length; |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our string_hashref::method $ast_to_rperl__generate = sub { |
47
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
48
|
|
|
|
|
|
|
my string_hashref $rperl_source_group = { PMC => q{} }; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# RPerl::diag( 'in Array::ListElements->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
if ( ( ref $self ) ne 'ListElements_190' ) { |
53
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( |
54
|
|
|
|
|
|
|
'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' . ( ref $self ) . ' found where ListElements_190 expected, dying' ) |
55
|
|
|
|
|
|
|
. "\n"; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my object $list_element0 = $self->{children}->[0]; |
59
|
|
|
|
|
|
|
my object $list_elements_star = $self->{children}->[1]; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# RPerl::diag( 'in Array::ListElements->ast_to_rperl__generate(), top of foreach() loop, have $list_element0 = ' . "\n" . RPerl::Parser::rperl_ast__dump($list_element0) . "\n" ); |
62
|
|
|
|
|
|
|
# die 'TMP DEBUG'; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my string_hashref $rperl_source_subgroup = $list_element0->ast_to_rperl__generate($modes); |
65
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
foreach my object $list_element ( @{ $list_elements_star->{children} } ) { |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# RPerl::diag( 'in Array::ListElements->ast_to_rperl__generate(), top of foreach() loop, have $list_element = ' . "\n" . RPerl::Parser::rperl_ast__dump($list_element) . "\n" ); |
70
|
|
|
|
|
|
|
# die 'TMP DEBUG'; |
71
|
|
|
|
|
|
|
if ( ref $list_element eq 'TERMINAL' ) { |
72
|
|
|
|
|
|
|
if ( $list_element->{attr} ne q{,} ) { |
73
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( q{ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '} |
74
|
|
|
|
|
|
|
. $list_element->{attr} |
75
|
|
|
|
|
|
|
. q{' found where OP21_LIST_COMMA ',' expected, dying} ) |
76
|
|
|
|
|
|
|
. "\n"; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
$rperl_source_group->{PMC} .= $list_element->{attr} . q{ }; # OP21_LIST_COMMA |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
|
|
|
|
|
|
my string_hashref $rperl_source_subgroup = $list_element->ast_to_rperl__generate($modes); |
82
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
return $rperl_source_group; |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub { |
90
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
91
|
|
|
|
|
|
|
my string_hashref $cpp_source_group = { CPP => q{// <<< RP::DS::A::LEs __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" }; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#... |
94
|
|
|
|
|
|
|
return $cpp_source_group; |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
our string_hashref::method $ast_to_cpp__generate__CPPOPS_CPPTYPES = sub { |
98
|
|
|
|
|
|
|
( my object $self, my string_hashref $modes) = @_; |
99
|
|
|
|
|
|
|
my string_hashref $cpp_source_group = { CPP => q{} }; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# RPerl::diag( 'in Array::ListElements->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" ); |
102
|
|
|
|
|
|
|
# RPerl::diag( 'in Array::ListElements->ast_to_cpp__generate__CPPOPS_CPPTYPES(), have $modes->{_inside_print_operator} = ' . $modes->{_inside_print_operator} . "\n" ); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
if ( ( ref $self ) ne 'ListElements_190' ) { |
105
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( |
106
|
|
|
|
|
|
|
'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' . ( ref $self ) . ' found where ListElements_190 expected, dying' ) |
107
|
|
|
|
|
|
|
. "\n"; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# save to stack of saved flags, when needed |
111
|
|
|
|
|
|
|
if ( ( exists $modes->{_inside_list_elements} ) and ( defined $modes->{_inside_list_elements} ) ) { |
112
|
|
|
|
|
|
|
if ( ( not exists $modes->{_inside_list_elements_saved} ) or ( not defined $modes->{_inside_list_elements_saved} ) ) { |
113
|
|
|
|
|
|
|
$modes->{_inside_list_elements_saved} = []; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
push @{ $modes->{_inside_list_elements_saved} }, $modes->{_inside_list_elements}; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
$modes->{_inside_list_elements} = 1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my object $list_element0 = $self->{children}->[0]; |
120
|
|
|
|
|
|
|
my object $list_elements_star = $self->{children}->[1]; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my string_hashref $cpp_source_subgroup = $list_element0->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); |
123
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
foreach my object $list_element ( @{ $list_elements_star->{children} } ) { |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# RPerl::diag( 'in Array::ListElements->ast_to_cpp__generate__CPPOPS_CPPTYPES(), top of foreach() loop, have $list_element = ' . "\n" . RPerl::Parser::rperl_ast__dump($list_element) . "\n" ); |
128
|
|
|
|
|
|
|
if ( ref $list_element eq 'TERMINAL' ) { |
129
|
|
|
|
|
|
|
if ( $list_element->{attr} ne q{,} ) { |
130
|
|
|
|
|
|
|
die RPerl::Parser::rperl_rule__replace( q{ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '} |
131
|
|
|
|
|
|
|
. $list_element->{attr} |
132
|
|
|
|
|
|
|
. q{' found where OP21_LIST_COMMA ',' expected, dying} ) |
133
|
|
|
|
|
|
|
. "\n"; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# OP21_LIST_COMMA |
137
|
|
|
|
|
|
|
if ( ( exists $modes->{_inside_print_operator} ) and ( defined $modes->{_inside_print_operator} ) and $modes->{_inside_print_operator} ) { # or |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# ((exists $modes->{_inside_die_operator}) and (defined $modes->{_inside_die_operator}) and $modes->{_inside_die_operator})) { # DEV NOTE, CORRELATION #rp102b |
140
|
|
|
|
|
|
|
# replace comma with << when inside print operator |
141
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= ' << '; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
else { |
144
|
|
|
|
|
|
|
# keep comma when not inside print operator |
145
|
|
|
|
|
|
|
$cpp_source_group->{CPP} .= $list_element->{attr} . q{ }; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
else { |
149
|
|
|
|
|
|
|
my string_hashref $cpp_source_subgroup = $list_element->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes); |
150
|
|
|
|
|
|
|
RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup ); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# restore from stack of saved flags, when needed |
155
|
|
|
|
|
|
|
delete $modes->{_inside_list_elements}; |
156
|
|
|
|
|
|
|
if ( ( exists $modes->{_inside_list_elements_saved} ) |
157
|
|
|
|
|
|
|
and ( defined $modes->{_inside_list_elements_saved} ) |
158
|
|
|
|
|
|
|
and ( scalar $modes->{_inside_list_elements_saved} ) ) |
159
|
|
|
|
|
|
|
{ |
160
|
|
|
|
|
|
|
$modes->{_inside_list_elements} = pop @{ $modes->{_inside_list_elements_saved} }; |
161
|
|
|
|
|
|
|
if ( not scalar $modes->{_inside_list_elements_saved} ) { delete $modes->{_inside_list_elements_saved}; } |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
return $cpp_source_group; |
165
|
|
|
|
|
|
|
}; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
1; # end of class |