Skip to content

Commit

Permalink
Merge pull request #392 from stfc/335_add_block
Browse files Browse the repository at this point in the history
(Closes #335, #326) add block and critical
  • Loading branch information
sergisiso authored Apr 3, 2023
2 parents 95eb99a + a766ac1 commit 32c9e45
Show file tree
Hide file tree
Showing 16 changed files with 866 additions and 274 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Modifications by (in alphabetical order):
* P. Vitt, University of Siegen, Germany
* A. Voysey, UK Met Office

03/04/2023 PR #392 for #326. Add support for F2008 block and critical constructs.

30/03/2023 PR #396 for #395. Fix trailing whitespace bug in CallBase.

13/03/2023 PR #391 for #324. Add GH workfow to automate a pypi upload during
Expand Down
19 changes: 12 additions & 7 deletions doc/source/developers_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ returned. An example of a simple choice rule is `R202`. See the
:ref:`program-unit-class` section for a description of its
implementation.

.. note::

A `use_names` description, explanation and example needs to be added.
The `use_names` list should contain any classes that are referenced by the
implementation of the current class. These lists of names are aggregated
(along with `subclass_names`) and used to ensure that all necessary `Scalar_`,
`_List` and `_Name` classes are generated (in code at the end of the
`Fortran2003` and `Fortran2008` modules - see :ref:`class-generation`).

When the rule is not a simple choice the developer needs to supply a
static `match` method. An example of this is rule `R201`. See the
Expand Down Expand Up @@ -294,10 +296,13 @@ there is no name associated with such a program, the corresponding
symbol table is given the name "fparser2:main_program", chosen so as
to prevent any clashes with other Fortran names.

Those classes taken to define scoping regions are stored as
a list within the `SymbolTables` instance. This list is populated
after the class hierarchy has been constructed for the parser (since
this depends on which Fortran standard has been chosen).
Those classes which define scoping regions must subclass the
`ScopingRegionMixin` class:

.. autoclass:: fparser.two.utils.ScopingRegionMixin


.. _class-generation:

Class Generation
++++++++++++++++
Expand Down
9 changes: 6 additions & 3 deletions src/fparser/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
# Maximum number of characters on a single line. Black's default is 88.
max-line-length=88

# fparser dynamically generates *_List classes so pylint can't
# find them.
generated-members=Fortran2003.*_List,Fortran2008.*_List
[TYPECHECK]

# fparser generates *_List classes at runtime so pylint can't
# find them (as it's a static checker).
ignored-modules=fparser.two.Fortran2003,fparser.two.Fortran2008
generated-members=fparser.two.Fortran2003.*_List,fparser.two.Fortran2008.*_List

[DESIGN]
# Maximum number of parents for a class (see R0901)
Expand Down
17 changes: 12 additions & 5 deletions src/fparser/two/Fortran2003.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
CALLBase,
CallBase,
KeywordValueBase,
ScopingRegionMixin,
SeparatorBase,
SequenceBase,
UnaryOpBase,
Expand Down Expand Up @@ -7036,7 +7037,13 @@ class If_Construct(BlockBase): # R802
"""

subclass_names = []
use_names = ["If_Then_Stmt", "Block", "Else_If_Stmt", "Else_Stmt", "End_If_Stmt"]
use_names = [
"If_Then_Stmt",
"Execution_Part_Construct",
"Else_If_Stmt",
"Else_Stmt",
"End_If_Stmt",
]

@staticmethod
def match(string):
Expand Down Expand Up @@ -10882,7 +10889,7 @@ def match(reader):
return result


class Program_Stmt(StmtBase, WORDClsBase): # R1102
class Program_Stmt(StmtBase, WORDClsBase, ScopingRegionMixin): # R1102
"""
Fortran 2003 rule R1102::
Expand Down Expand Up @@ -10973,7 +10980,7 @@ def match(reader):
)


class Module_Stmt(StmtBase, WORDClsBase): # R1105
class Module_Stmt(StmtBase, WORDClsBase, ScopingRegionMixin): # R1105
"""
<module-stmt> = MODULE <module-name>
"""
Expand Down Expand Up @@ -12472,7 +12479,7 @@ def match(reader):
)


class Function_Stmt(StmtBase): # R1224
class Function_Stmt(StmtBase, ScopingRegionMixin): # R1224
"""
::
Expand Down Expand Up @@ -12790,7 +12797,7 @@ def c1242_valid(prefix, binding_spec):
return True


class Subroutine_Stmt(StmtBase): # R1232
class Subroutine_Stmt(StmtBase, ScopingRegionMixin): # R1232
"""
Fortran2003 rule R1232::
Expand Down
Loading

0 comments on commit 32c9e45

Please sign in to comment.