Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Fortran2008.py into separate files (closes #411) #425

Merged
merged 9 commits into from
Sep 14, 2023
Merged
1,765 changes: 0 additions & 1,765 deletions src/fparser/two/Fortran2008/Fortran2008.py

This file was deleted.

84 changes: 42 additions & 42 deletions src/fparser/two/Fortran2008/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,50 +41,50 @@
import sys

from fparser.two.Fortran2003 import Base, SequenceBase
from fparser.two.Fortran2008.Fortran2008 import (
Program_Unit,
Executable_Construct,
Executable_Construct_C201,
Action_Stmt,
Action_Stmt_C201,
Action_Stmt_C816,
Action_Stmt_C828,
Data_Component_Def_Stmt,
Component_Attr_Spec,
Type_Declaration_Stmt,
Codimension_Attr_Spec,
Coarray_Bracket_Spec,
Attr_Spec,
Coarray_Spec,
Deferred_Coshape_Spec,
Explicit_Coshape_Spec,
Coshape_Spec,
Lower_Cobound,
Upper_Cobound,
Do_Term_Action_Stmt,
Alloc_Opt,
Allocate_Stmt,
Loop_Control,
If_Stmt,
Error_Stop_Stmt,
Specification_Part_C1112,
Implicit_Part_C1112,
Implicit_Part_Stmt_C1112,
from fparser.two.Fortran2008.program_unit_r202 import Program_Unit
from fparser.two.Fortran2008.executable_construct_r213 import Executable_Construct
from fparser.two.Fortran2008.executable_construct_c201 import Executable_Construct_C201
from fparser.two.Fortran2008.action_stmt_r214 import Action_Stmt
from fparser.two.Fortran2008.action_stmt_c201 import Action_Stmt_C201
from fparser.two.Fortran2008.action_stmt_c816 import Action_Stmt_C816
from fparser.two.Fortran2008.action_stmt_c828 import Action_Stmt_C828
from fparser.two.Fortran2008.data_component_def_stmt_r436 import Data_Component_Def_Stmt
from fparser.two.Fortran2008.component_attr_spec_r437 import Component_Attr_Spec
from fparser.two.Fortran2008.type_declaration_stmt_r501 import Type_Declaration_Stmt
from fparser.two.Fortran2008.codimension_attr_spec_r502d import Codimension_Attr_Spec
from fparser.two.Fortran2008.coarray_bracket_spec_r502d0 import Coarray_Bracket_Spec
from fparser.two.Fortran2008.attr_spec_r502 import Attr_Spec
from fparser.two.Fortran2008.coarray_spec_r509 import Coarray_Spec
from fparser.two.Fortran2008.deferred_coshape_spec_r510 import Deferred_Coshape_Spec
from fparser.two.Fortran2008.explicit_coshape_spec_r511 import Explicit_Coshape_Spec
from fparser.two.Fortran2008.coshape_spec_r511a import Coshape_Spec
from fparser.two.Fortran2008.lower_cobound_r512 import Lower_Cobound
from fparser.two.Fortran2008.upper_cobound_r513 import Upper_Cobound
from fparser.two.Fortran2008.do_term_action_stmt_r826 import Do_Term_Action_Stmt
from fparser.two.Fortran2008.alloc_opt_r627 import Alloc_Opt
from fparser.two.Fortran2008.allocate_stmt_r626 import Allocate_Stmt
from fparser.two.Fortran2008.loop_control_r818 import Loop_Control
from fparser.two.Fortran2008.if_stmt_r837 import If_Stmt
from fparser.two.Fortran2008.error_stop_stmt_r856 import Error_Stop_Stmt
from fparser.two.Fortran2008.specification_part_c1112 import Specification_Part_C1112
from fparser.two.Fortran2008.implicit_part_c1112 import Implicit_Part_C1112
from fparser.two.Fortran2008.implicit_part_stmt_c1112 import Implicit_Part_Stmt_C1112
from fparser.two.Fortran2008.declaration_construct_c1112 import (
Declaration_Construct_C1112,
Submodule,
Submodule_Stmt,
End_Submodule_Stmt,
Parent_Identifier,
Open_Stmt,
Connect_Spec,
Block_Construct,
Block_Stmt,
End_Block_Stmt,
Critical_Construct,
Critical_Stmt,
End_Critical_Stmt,
Procedure_Stmt,
)
from fparser.two.Fortran2008.submodule_r1116 import Submodule
from fparser.two.Fortran2008.submodule_stmt_r1117 import Submodule_Stmt
from fparser.two.Fortran2008.end_submodule_stmt_r1119 import End_Submodule_Stmt
from fparser.two.Fortran2008.parent_identifier_r1118 import Parent_Identifier
from fparser.two.Fortran2008.open_stmt_r904 import Open_Stmt
from fparser.two.Fortran2008.connect_spec_r905 import Connect_Spec
from fparser.two.Fortran2008.block_construct_r807 import Block_Construct
from fparser.two.Fortran2008.block_stmt_r808 import Block_Stmt
from fparser.two.Fortran2008.end_block_stmt_r809 import End_Block_Stmt
from fparser.two.Fortran2008.critical_construct_r810 import Critical_Construct
from fparser.two.Fortran2008.critical_stmt_r811 import Critical_Stmt
from fparser.two.Fortran2008.end_critical_stmt_r812 import End_Critical_Stmt
from fparser.two.Fortran2008.procedure_stmt_r1206 import Procedure_Stmt

from fparser.two.Fortran2008.action_term_do_construct_r824 import (
Action_Term_Do_Construct,
Expand Down
50 changes: 50 additions & 0 deletions src/fparser/two/Fortran2008/action_stmt_c201.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -----------------------------------------------------------------------------
# BSD 3-Clause License
#
# Copyright (c) 2023, Science and Technology Facilities Council.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------

"""
Module containing Fortran2008 Action_Stmt constraint C201
"""
from fparser.two.Fortran2003 import Action_Stmt_C201 as Action_Stmt_C201_2003
from fparser.two.Fortran2008.action_stmt_r214 import Action_Stmt


class Action_Stmt_C201(Action_Stmt_C201_2003):
"""
action-stmt-c201 is action-stmt
C201 is applied.
"""

subclass_names = Action_Stmt.subclass_names[:]
subclass_names.remove("End_Function_Stmt")
subclass_names.remove("End_Subroutine_Stmt")
58 changes: 58 additions & 0 deletions src/fparser/two/Fortran2008/action_stmt_c816.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -----------------------------------------------------------------------------
# BSD 3-Clause License
#
# Copyright (c) 2023, Science and Technology Facilities Council.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------

"""
Module containing Fortran2008 Action_Stmt constraint C816
"""
from fparser.two.Fortran2003 import Action_Stmt_C824 as Action_Stmt_C824_2003
from fparser.two.Fortran2008.action_stmt_r214 import Action_Stmt


class Action_Stmt_C816(Action_Stmt_C824_2003):
"""
action-stmt-c816 is action-stmt
C816 is applied.
"""

subclass_names = Action_Stmt.subclass_names[:]
subclass_names.remove("Arithmetic_If_Stmt")
subclass_names.remove("Continue_Stmt")
subclass_names.remove("Cycle_Stmt")
subclass_names.remove("End_Function_Stmt")
subclass_names.remove("End_Subroutine_Stmt")
subclass_names.remove("Error_Stop_Stmt")
subclass_names.remove("Exit_Stmt")
subclass_names.remove("Goto_Stmt")
subclass_names.remove("Return_Stmt")
subclass_names.remove("Stop_Stmt")
51 changes: 51 additions & 0 deletions src/fparser/two/Fortran2008/action_stmt_c828.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -----------------------------------------------------------------------------
# BSD 3-Clause License
#
# Copyright (c) 2023, Science and Technology Facilities Council.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------

"""
Module containing Fortran2008 Action_Stmt constraint C828
"""
from fparser.two.Fortran2003 import Action_Stmt_C802 as Action_Stmt_C802_2003
from fparser.two.Fortran2008.action_stmt_r214 import Action_Stmt


class Action_Stmt_C828(Action_Stmt_C802_2003):
"""
action-stmt-c828 is action-stmt
C828 is applied.
"""

subclass_names = Action_Stmt.subclass_names[:]
subclass_names.remove("End_Function_Stmt")
subclass_names.remove("End_Subroutine_Stmt")
subclass_names.remove("If_Stmt")
103 changes: 103 additions & 0 deletions src/fparser/two/Fortran2008/action_stmt_r214.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# -----------------------------------------------------------------------------
# BSD 3-Clause License
#
# Copyright (c) 2023, Science and Technology Facilities Council.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------

"""
Module containing Fortran2008 Action_Stmt rule R214
"""
from fparser.two.Fortran2003 import Action_Stmt as Action_Stmt_2003


class Action_Stmt(Action_Stmt_2003): # R214
"""
Fortran 2008 rule R214.

.. code-block:: fortran

action-stmt is allocate-stmt
or assignment-stmt
or backspace-stmt
or call-stmt
or close-stmt
or continue-stmt
or cycle-stmt
or deallocate-stmt
or end-function-stmt
or end-mp-subprogram-stmt
or end-program-stmt
or end-subroutine-stmt
or endfile-stmt
or error-stop-stmt
or exit-stmt
or flush-stmt
or forall-stmt
or goto-stmt
or if-stmt
or inquire-stmt
or lock-stmt
or nullify-stmt
or open-stmt
or pointer-assignment-stmt
or print-stmt
or read-stmt
or return-stmt
or rewind-stmt
or stop-stmt
or sync-all-stmt
or sync-images-stmt
or sync-memory-stmt
or unlock-stmt
or wait-stmt
or where-stmt
or write-stmt
or arithmetic-if-stmt
or computed-goto-stmt

The implementation of this rule adds the relevant subclass names
for new statements added in Fortran 2008.

Associated constraints are:

"C201 (R208) An execution-part shall not contain an end-function-stmt,
end-mp-subprogram-stmt, end-program-stmt, or end-subroutine-stmt."

NB: The following statements are not yet implemented:
end-mp-subprogram-stmt, endfile-stmt, lock-stmt, sync-all-stmt,
sync-images-stmt, sync-memory-stmt, unlock-stmt.

"""

# Fortran 2008 adds a few additional action-stmt. We therefore
# extend the Fortran 2003 specification
subclass_names = Action_Stmt_2003.subclass_names[:]
subclass_names.append("Error_Stop_Stmt")
Loading