Skip to content

Commit 32c9e45

Browse files
authored
Merge pull request #392 from stfc/335_add_block
(Closes #335, #326) add block and critical
2 parents 95eb99a + a766ac1 commit 32c9e45

16 files changed

+866
-274
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Modifications by (in alphabetical order):
1818
* P. Vitt, University of Siegen, Germany
1919
* A. Voysey, UK Met Office
2020

21+
03/04/2023 PR #392 for #326. Add support for F2008 block and critical constructs.
22+
2123
30/03/2023 PR #396 for #395. Fix trailing whitespace bug in CallBase.
2224

2325
13/03/2023 PR #391 for #324. Add GH workfow to automate a pypi upload during

doc/source/developers_guide.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ returned. An example of a simple choice rule is `R202`. See the
170170
:ref:`program-unit-class` section for a description of its
171171
implementation.
172172

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

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

297-
Those classes taken to define scoping regions are stored as
298-
a list within the `SymbolTables` instance. This list is populated
299-
after the class hierarchy has been constructed for the parser (since
300-
this depends on which Fortran standard has been chosen).
299+
Those classes which define scoping regions must subclass the
300+
`ScopingRegionMixin` class:
301+
302+
.. autoclass:: fparser.two.utils.ScopingRegionMixin
303+
304+
305+
.. _class-generation:
301306

302307
Class Generation
303308
++++++++++++++++

src/fparser/.pylintrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
# Maximum number of characters on a single line. Black's default is 88.
44
max-line-length=88
55

6-
# fparser dynamically generates *_List classes so pylint can't
7-
# find them.
8-
generated-members=Fortran2003.*_List,Fortran2008.*_List
6+
[TYPECHECK]
7+
8+
# fparser generates *_List classes at runtime so pylint can't
9+
# find them (as it's a static checker).
10+
ignored-modules=fparser.two.Fortran2003,fparser.two.Fortran2008
11+
generated-members=fparser.two.Fortran2003.*_List,fparser.two.Fortran2008.*_List
912

1013
[DESIGN]
1114
# Maximum number of parents for a class (see R0901)

src/fparser/two/Fortran2003.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
CALLBase,
9494
CallBase,
9595
KeywordValueBase,
96+
ScopingRegionMixin,
9697
SeparatorBase,
9798
SequenceBase,
9899
UnaryOpBase,
@@ -7036,7 +7037,13 @@ class If_Construct(BlockBase): # R802
70367037
"""
70377038

70387039
subclass_names = []
7039-
use_names = ["If_Then_Stmt", "Block", "Else_If_Stmt", "Else_Stmt", "End_If_Stmt"]
7040+
use_names = [
7041+
"If_Then_Stmt",
7042+
"Execution_Part_Construct",
7043+
"Else_If_Stmt",
7044+
"Else_Stmt",
7045+
"End_If_Stmt",
7046+
]
70407047

70417048
@staticmethod
70427049
def match(string):
@@ -10882,7 +10889,7 @@ def match(reader):
1088210889
return result
1088310890

1088410891

10885-
class Program_Stmt(StmtBase, WORDClsBase): # R1102
10892+
class Program_Stmt(StmtBase, WORDClsBase, ScopingRegionMixin): # R1102
1088610893
"""
1088710894
Fortran 2003 rule R1102::
1088810895
@@ -10973,7 +10980,7 @@ def match(reader):
1097310980
)
1097410981

1097510982

10976-
class Module_Stmt(StmtBase, WORDClsBase): # R1105
10983+
class Module_Stmt(StmtBase, WORDClsBase, ScopingRegionMixin): # R1105
1097710984
"""
1097810985
<module-stmt> = MODULE <module-name>
1097910986
"""
@@ -12472,7 +12479,7 @@ def match(reader):
1247212479
)
1247312480

1247412481

12475-
class Function_Stmt(StmtBase): # R1224
12482+
class Function_Stmt(StmtBase, ScopingRegionMixin): # R1224
1247612483
"""
1247712484
::
1247812485
@@ -12790,7 +12797,7 @@ def c1242_valid(prefix, binding_spec):
1279012797
return True
1279112798

1279212799

12793-
class Subroutine_Stmt(StmtBase): # R1232
12800+
class Subroutine_Stmt(StmtBase, ScopingRegionMixin): # R1232
1279412801
"""
1279512802
Fortran2003 rule R1232::
1279612803

0 commit comments

Comments
 (0)