File Coverage

blib/lib/RPerl/Operation/Statement/OperatorVoid/LoopControl.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Operation::Statement::OperatorVoid::LoopControl;
3 5     5   35 use strict;
  5         13  
  5         146  
4 5     5   28 use warnings;
  5         13  
  5         115  
5 5     5   27 use RPerl::AfterSubclass;
  5         12  
  5         687  
6             our $VERSION = 0.002_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 5     5   38 use parent qw(RPerl::Operation::Statement::OperatorVoid);
  5         13  
  5         44  
10 5     5   306 use RPerl::Operation::Statement::OperatorVoid;
  5         13  
  5         2955  
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 OperatorVoid::LoopControl->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 'OperatorVoid_123' ) { # OperatorVoid -> OP19_LOOP_CONTROL_SCOLON
30             if (($self->{children}->[0] ne 'next;') and ($self->{children}->[0] ne 'last;')) {
31             die RPerl::Parser::rperl_rule__replace(
32             'ERROR ECOGEASRP26, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: loop control operator '
33             . $self->{children}->[0]
34             . ' found where next; or last; expected, dying'
35             ) . "\n";
36             }
37             $rperl_source_group->{PMC} .= $self->{children}->[0] . "\n";
38             }
39             elsif ( $self_class eq 'OperatorVoid_124' ) { # OperatorVoid -> OP19_LOOP_CONTROL LoopLabel ';'
40             my string $loop_control = $self->{children}->[0];
41             my string $loop_label = $self->{children}->[1]->{children}->[0];
42             my string $semicolon = $self->{children}->[2];
43             $rperl_source_group->{PMC} .= $loop_control . q{ } . $loop_label . $semicolon . "\n";
44            
45            
46            
47             if (($loop_control !~ /^next/xms) and ($loop_control !~ /^last/xms) and ($loop_control !~ /^redo/xms)) {
48             die RPerl::Parser::rperl_rule__replace(
49             'ERROR ECOGEASCP27, CODE GENERATOR, ABSTRACT SYNTAX TO C++: loop control operator '
50             . $loop_control
51             . ' found where next, last, or redo expected, dying'
52             ) . "\n";
53             }
54             }
55             else {
56             die RPerl::Parser::rperl_rule__replace(
57             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
58             . $self_class
59             . ' found where OperatorVoid_123 or OperatorVoid_124 expected, dying'
60             ) . "\n";
61             }
62              
63             return $rperl_source_group;
64             };
65              
66             our string_hashref::method $ast_to_cpp__generate__CPPOPS_PERLTYPES = sub {
67             ( my object $self, my string_hashref $modes) = @_;
68             my string_hashref $cpp_source_group
69             = { CPP =>
70             q{// <<< RP::O::S::OV::LC __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
71             . "\n" };
72              
73             #...
74             return $cpp_source_group;
75             };
76              
77             our string_hashref::method $ast_to_cpp__generate__CPPOPS_CPPTYPES = sub {
78             ( my object $self, my string_hashref $modes) = @_;
79             my string_hashref $cpp_source_group = { CPP => q{} };
80             my string_hashref $cpp_source_subgroup;
81              
82             # RPerl::diag( 'in OperatorVoid::LoopControl->$ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
83              
84             my string $self_class = ref $self;
85             if ( $self_class eq 'OperatorVoid_123' ) { # OperatorVoid -> OP19_LOOP_CONTROL_SCOLON
86             if ($self->{children}->[0] eq 'next;') {
87             $cpp_source_group->{CPP} .= 'continue;' . "\n";
88             }
89             elsif ($self->{children}->[0] eq 'last;') {
90             $cpp_source_group->{CPP} .= 'break;' . "\n";
91             }
92             else {
93             die RPerl::Parser::rperl_rule__replace(
94             'ERROR ECOGEASCP26, CODE GENERATOR, ABSTRACT SYNTAX TO C++: loop control operator '
95             . $self->{children}->[0]
96             . ' found where next; or last; expected, dying'
97             ) . "\n";
98             }
99             }
100             elsif ( $self_class eq 'OperatorVoid_124' ) { # OperatorVoid -> OP19_LOOP_CONTROL LoopLabel ';'
101             my string $loop_control = $self->{children}->[0];
102             my string $loop_label = $self->{children}->[1]->{children}->[0];
103             my string $semicolon = $self->{children}->[2];
104             if ($loop_control =~ /^next/xms) {
105             $cpp_source_group->{CPP} .= 'goto ' . $loop_label . '_NEXT' . $semicolon . "\n";
106             }
107             elsif ($loop_control =~ /^last/xms) {
108             $cpp_source_group->{CPP} .= 'goto ' . $loop_label . '_LAST' . $semicolon . "\n";
109             }
110             elsif ($loop_control =~ /^redo/xms) {
111             $cpp_source_group->{CPP} .= 'goto ' . $loop_label . '_REDO' . $semicolon . "\n";
112             }
113             else {
114             die RPerl::Parser::rperl_rule__replace(
115             'ERROR ECOGEASCP27, CODE GENERATOR, ABSTRACT SYNTAX TO C++: loop control operator '
116             . $loop_control
117             . ' found where next, last, or redo expected, dying'
118             ) . "\n";
119             }
120             }
121             else {
122             die RPerl::Parser::rperl_rule__replace(
123             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
124             . $self_class
125             . ' found where OperatorVoid_123 or OperatorVoid_124 expected, dying'
126             ) . "\n";
127             }
128             return $cpp_source_group;
129             };
130              
131             1; # end of class