our
$VERSION
= 0.004_000;
if
(
$EVAL_ERROR
and (
$EVAL_ERROR
=~ /attempt to reload/i)){
delete
$INC
{
'RPerl::Parser'
};
}
elsif
(
$EVAL_ERROR
ne
q{}
) {
die
$EVAL_ERROR
; }
our
hashref
$properties
= {};
sub
ast_to_rperl__generate {
{
my
string_hashref::method
$RETURN_TYPE
};
(
my
object
$self
,
my
string_hashref
$modes
) =
@ARG
;
my
string_hashref
$rperl_source_group
= {};
my
object_arrayref
$modules_and_headers
=
$self
->{children}->[0]->{children};
my
string_hashref
$rperl_source_subgroup
;
my
string
$package_name_underscores
;
my
boolean
$header_started
= 0;
my
boolean
$current_package_count
= 0;
foreach
my
object
$header_or_module
(@{
$modules_and_headers
}) {
if
((
ref
$header_or_module
) eq
'ModuleHeader_23'
) {
if
(
$header_started
) {
die
'ERROR ECOGEASRP034, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: ModuleHeader found without first finding Module for previous ModuleHeader, dying'
.
"\n"
;
}
else
{
if
((
$current_package_count
== 1) and (
$modes
->{label} eq
'ON'
)) {
$rperl_source_group
->{PMC} .=
'# [[[ ADDITIONAL CLASSES ]]]'
.
"\n\n"
;
}
$header_started
= 1;
$rperl_source_subgroup
=
$header_or_module
->ast_to_rperl__generate(
$modes
);
$package_name_underscores
=
$rperl_source_subgroup
->{_package_name_underscores};
RPerl::Generator::source_group_append(
$rperl_source_group
,
$rperl_source_subgroup
);
}
}
elsif
(((
ref
$header_or_module
) eq
'Module_24'
) or ((
ref
$header_or_module
) eq
'Module_25'
)) {
if
(
$header_started
) {
$rperl_source_subgroup
=
$header_or_module
->ast_to_rperl__generate(
$package_name_underscores
,
$modes
);
RPerl::Generator::source_group_append(
$rperl_source_group
,
$rperl_source_subgroup
);
$header_started
= 0;
$current_package_count
++;
}
else
{
die
'ERROR ECOGEASRP035, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Module found without first finding ModuleHeader, dying'
.
"\n"
;
}
}
else
{
die
RPerl::Parser::rperl_rule__replace(
'ERROR ECOGEASRP000, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
. (
ref
$header_or_module
)
.
' found where ModuleHeader_23, Module_24, or Module_25 expected, dying'
)
.
"\n"
;
}
}
return
$rperl_source_group
;
}
sub
ast_to_cpp__generate__CPPOPS_PERLTYPES {
{
my
string_hashref::method
$RETURN_TYPE
};
(
my
object
$self
,
my
string_hashref
$modes
) =
@ARG
;
my
string_hashref
$cpp_source_group
= {
CPP
=>
q{// <<< RP::CU::M __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
.
"\n"
,
H
=>
q{// <<< RP::CU::M __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
.
"\n"
,
PMC
=>
q{# <<< RP::CU::M __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
.
"\n"
};
return
$cpp_source_group
;
}
sub
ast_to_cpp__generate__CPPOPS_CPPTYPES {
{
my
string_hashref::method
$RETURN_TYPE
};
(
my
object
$self
,
my
string_hashref
$modes
) =
@ARG
;
my
string_hashref
$cpp_source_group
= {
CPP
=>
q{}
,
H
=>
q{}
};
my
object_arrayref
$modules_and_headers
=
$self
->{children}->[0]->{children};
my
string_hashref
$cpp_source_subgroup
;
my
string_hashref
$cpp_source_subgroup_saved
;
my
string
$package_name_underscores
;
my
boolean
$header_started
= 0;
my
boolean
$current_package_count
= 0;
foreach
my
object
$header_or_module
(@{
$modules_and_headers
}) {
if
((
ref
$header_or_module
) eq
'ModuleHeader_23'
) {
if
(
$header_started
) {
die
'ERROR ECOGEASCP034, CODE GENERATOR, ABSTRACT SYNTAX TO C++, CPPOPS_CPPTYPES: ModuleHeader found without first finding Module for previous ModuleHeader, dying'
.
"\n"
;
}
else
{
if
(
$current_package_count
>= 1) {
$cpp_source_group
->{CPP} .=
"\n\n"
;
$cpp_source_group
->{H} .=
"\n\n"
;
}
if
((
$current_package_count
== 1) and (
$modes
->{label} eq
'ON'
)) {
$cpp_source_group
->{CPP} .=
'// [[[ ADDITIONAL CLASSES ]]]'
.
"\n\n"
;
$cpp_source_group
->{H} .=
'// [[[ ADDITIONAL CLASSES ]]]'
.
"\n\n"
;
}
$header_started
= 1;
$cpp_source_subgroup
=
$header_or_module
->ast_to_cpp__generate_begin__CPPOPS_CPPTYPES(
$modes
);
$package_name_underscores
=
$cpp_source_subgroup
->{_package_name_underscores};
RPerl::Generator::source_group_append(
$cpp_source_group
,
$cpp_source_subgroup
);
$cpp_source_subgroup_saved
=
$header_or_module
->ast_to_cpp__generate_end__CPPOPS_CPPTYPES(
$modes
);
}
}
elsif
(((
ref
$header_or_module
) eq
'Module_24'
) or ((
ref
$header_or_module
) eq
'Module_25'
)) {
if
(
$header_started
) {
$cpp_source_subgroup
=
$header_or_module
->ast_to_cpp__generate__CPPOPS_CPPTYPES(
$package_name_underscores
, {%{
$modes
},
current_package_count
=>
$current_package_count
});
RPerl::Generator::source_group_append(
$cpp_source_group
,
$cpp_source_subgroup
);
RPerl::Generator::source_group_append(
$cpp_source_group
,
$cpp_source_subgroup_saved
);
$header_started
= 0;
$cpp_source_group
->{CPP} .=
"\n"
.
'// end of class'
.
"\n"
;
$cpp_source_group
->{H} .=
"\n"
.
'// end of class'
.
"\n"
;
$current_package_count
++;
}
else
{
die
'ERROR ECOGEASCP035, CODE GENERATOR, ABSTRACT SYNTAX TO C++, CPPOPS_CPPTYPES: Module found without first finding ModuleHeader, dying'
.
"\n"
;
}
}
else
{
die
RPerl::Parser::rperl_rule__replace(
'ERROR ECOGEASCP000, CODE GENERATOR, ABSTRACT SYNTAX TO C++, CPPOPS_CPPTYPES: Grammar rule '
. (
ref
$header_or_module
)
.
' found where ModuleHeader_23, Module_24, or Module_25 expected, dying'
)
.
"\n"
;
}
}
return
$cpp_source_group
;
}
1;