fparser.two.Fortran2008
Fortran 2008 module. Contains classes which extend the Fortran 2003 standard to implement the Fortran 2008 standard.
Submodules
fparser.two.Fortran2008.action_stmt_c201
fparser.two.Fortran2008.action_stmt_c816
fparser.two.Fortran2008.action_stmt_c828
fparser.two.Fortran2008.action_stmt_r214
fparser.two.Fortran2008.action_term_do_construct_r824
fparser.two.Fortran2008.alloc_opt_r627
fparser.two.Fortran2008.allocate_stmt_r626
fparser.two.Fortran2008.attr_spec_r502
fparser.two.Fortran2008.block_construct_r807
fparser.two.Fortran2008.block_label_do_construct_r814_1
fparser.two.Fortran2008.block_nonlabel_do_construct_r814_2
fparser.two.Fortran2008.block_stmt_r808
fparser.two.Fortran2008.coarray_bracket_spec_r502d0
fparser.two.Fortran2008.coarray_spec_r509
fparser.two.Fortran2008.codimension_attr_spec_r502d
fparser.two.Fortran2008.component_attr_spec_r437
fparser.two.Fortran2008.connect_spec_r905
fparser.two.Fortran2008.coshape_spec_r511a
fparser.two.Fortran2008.critical_construct_r810
fparser.two.Fortran2008.critical_stmt_r811
fparser.two.Fortran2008.data_component_def_stmt_r436
fparser.two.Fortran2008.declaration_construct_c1112
fparser.two.Fortran2008.deferred_coshape_spec_r510
fparser.two.Fortran2008.do_term_action_stmt_r826
fparser.two.Fortran2008.end_block_stmt_r809
fparser.two.Fortran2008.end_critical_stmt_r812
fparser.two.Fortran2008.end_submodule_stmt_r1119
fparser.two.Fortran2008.error_stop_stmt_r856
fparser.two.Fortran2008.executable_construct_c201
fparser.two.Fortran2008.executable_construct_r213
fparser.two.Fortran2008.explicit_coshape_spec_r511
fparser.two.Fortran2008.if_stmt_r837
fparser.two.Fortran2008.implicit_part_c1112
fparser.two.Fortran2008.implicit_part_stmt_c1112
fparser.two.Fortran2008.label_do_stmt_r816
fparser.two.Fortran2008.loop_control_r818
fparser.two.Fortran2008.lower_cobound_r512
fparser.two.Fortran2008.nonlabel_do_stmt_r817
fparser.two.Fortran2008.open_stmt_r904
fparser.two.Fortran2008.parent_identifier_r1118
fparser.two.Fortran2008.procedure_stmt_r1206
fparser.two.Fortran2008.program_unit_r202
fparser.two.Fortran2008.specification_part_c1112
fparser.two.Fortran2008.submodule_r1116
fparser.two.Fortran2008.submodule_stmt_r1117
fparser.two.Fortran2008.type_declaration_stmt_r501
fparser.two.Fortran2008.upper_cobound_r513
Package Contents
Classes
Base class for Fortran 2003 syntax rules. |
|
Match one or more fparser2 rules separated by a defined separator: |
|
Fortran 2008 rule R202. |
|
Fortran 2008 rule R213. |
|
executable-construct-c201 is executable construct. |
|
Fortran 2008 rule R214. |
|
action-stmt-c201 is action-stmt |
|
action-stmt-c816 is action-stmt |
|
action-stmt-c828 is action-stmt |
|
Fortran 2008 rule 436. |
|
Fortran 2008 rule R437. |
|
Fortran 2008 rule 501. |
|
codimension-attr-spec is CODIMENSION lbracket coarray-spec rbracket |
|
coarray-bracket-spec is lbracket coarray-spec rbracket |
|
Fortran 2008 rule R502. |
|
Fortran 2008 rule R509. |
|
Fortran 2008 rule R510 |
|
Fortran 2008 rule R511 |
|
coshape-spec is [ lower-cobound : ] upper-cobound |
|
Fortran 2008 rule R512 |
|
Fortran 2008 rule R513 |
|
Fortran 2008 rule R826. |
|
Fortran2008 rule R627. |
|
Fortran 2008 rule R626. |
|
Fortran 2008 rule R818 |
|
Fortran 2008 rule R837 |
|
Fortran 2008 rule R856 |
|
Fortran 2008 constraint C1112 |
|
Fortran 2008 constraint C1112 |
|
Fortran 2008 constraint C1112 |
|
Fortran 2008 constraint C1112 |
|
Fortran 2008 rule R1116. |
|
Fortran 2008 rule R1117: |
|
Fortran 2008 rule R1119 |
|
Fortran 2008 rule R1118 |
|
Fortran2008 Rule R904. |
|
Fortran2008 rule R905. Extends the Fortran2003 definition with support for |
|
Fortran 2008 Rule 807. |
|
Fortran 2008 Rule 808. |
|
Fortran 2008 Rule 809. |
|
Fortran 2008 Rule 810. |
|
Fortran 2008 Rule R811. |
|
Fortran 2008 Rule 812. |
|
Fortran 2008 Rule 1206. |
|
Subclass the 2003 version so that this class will import the |
|
Subclass the 2003 version so that this class will import the |
|
Subclass the 2003 version so that this class will import the |
|
Subclass the 2003 version so that this class will import the |
Attributes
- class fparser.two.Fortran2008.Base(string, parent_cls=None)[source]
Bases:
ComparableMixin
Base class for Fortran 2003 syntax rules.
All Base classes have the following attributes:
self.string - original argument to construct a class instance, its type is either str or FortranReaderBase. self.item - Line instance (holds label) or None.
- Parameters:
cls (type) – the class of object to create.
string (str |
fparser.common.readfortran.FortranReaderBase
) – (source of) Fortran string to parse.parent_cls (type) – the parent class of this object.
- property children
Return an iterable containing the immediate children of this node in the parse tree.
If this node represents an expression then its children are contained in a tuple which is immutable. Therefore, the manipulation of the children of such a node must be done by replacing the items property of the node directly rather than via the objects returned by this method.
- Returns:
the immediate children of this node.
- Return type:
list or tuple containing zero or more of
fparser.two.utils.Base
or NoneType or str
- subclasses
- get_root()[source]
Gets the node at the root of the parse tree to which this node belongs.
- Returns:
the node at the root of the parse tree.
- Return type:
- init(*items)[source]
Store the supplied list of nodes in the items list of this node.
- Parameters:
items (tuple of
fparser.two.utils.Base
) – the children of this node.
- class fparser.two.Fortran2008.SequenceBase(string, parent_cls=None)[source]
Bases:
Base
Match one or more fparser2 rules separated by a defined separator:
sequence-base is obj [sep obj ] ...
- static match(separator, subcls, string)[source]
Match one or more ‘subcls’ fparser2 rules in the string ‘string’ separated by ‘separator’.
- Parameters:
separator (str) – the separator used to split the supplied string.
subcls (subclass of
fparser.two.utils.Base
) – an fparser2 object representing the rule that should be matched.string (str) – the input string to match.
- Returns:
a tuple containing 1) the separator and 2) the matched objects in a tuple, or None if there is no match.
- Return type:
Optional[(Str,
fparser.two.utils.Base
)]- Raises:
InternalError – if the separator or string arguments are not the expected type.
InternalError – if the separator is white space.
- init(separator, items)[source]
Store the result of the match method if the match is successful.
- Parameters:
separator (str) – the separator used to split the supplied string.
items (tuple(Subclass of
fparser.two.utils.Base
)) – a tuple containing the matched objects.
- class fparser.two.Fortran2008.Program_Unit(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Program_Unit
Fortran 2008 rule R202.
program-unit is main-program or external-subprogram or module or submodule or block-data
- subclass_names
- class fparser.two.Fortran2008.Executable_Construct(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Executable_Construct
Fortran 2008 rule R213.
executable-construct is action-stmt or associate-construct or block-construct or case-construct or critical-construct or do-construct or forall-construct or if-construct or select-type-construct or where-construct
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.”
- subclass_names = ['Action_Stmt', 'Associate_Construct', 'Block_Construct', 'Case_Construct',...
- class fparser.two.Fortran2008.Executable_Construct_C201(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Executable_Construct_C201
executable-construct-c201 is executable construct. This applies C201.
- subclass_names
- class fparser.two.Fortran2008.Action_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Action_Stmt
Fortran 2008 rule R214.
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.
- subclass_names
- class fparser.two.Fortran2008.Action_Stmt_C201(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Action_Stmt_C201
action-stmt-c201 is action-stmt C201 is applied.
- subclass_names
- class fparser.two.Fortran2008.Action_Stmt_C816(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Action_Stmt_C824
action-stmt-c816 is action-stmt C816 is applied.
- subclass_names
- class fparser.two.Fortran2008.Action_Stmt_C828(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Action_Stmt_C802
action-stmt-c828 is action-stmt C828 is applied.
- subclass_names
- class fparser.two.Fortran2008.Data_Component_Def_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Data_Component_Def_Stmt
Fortran 2008 rule 436.
data-component-def-stmt is declaration-type-spec [ [ , component-attr-spec-list ] :: ] component-decl-list
The implementation of this rule does not add anything to the Fortran 2003 variant but reimplements the match method identical to Fortran 2003 as otherwise the generated Fortran 2008 variant of Component_Attr_Spec_List would not be used. Unfortunately, the required attr_spec_list_cls can not simply be provided as a class property since the relevant class is only generated at the end of this file using the use_names class property of this class.
Associated constraints are:
- “C439 (R436) No component-attr-spec shall appear more than once in a given
component-def-stmt.”
- “C440 (R436) If neither the POINTER nor the ALLOCATABLE attribute is
specified, the declaration-type-spec in the component-def-stmt shall specify an intrinsic type or a previously defined derived type.”
- “C441 (R436) If the POINTER or ALLOCATABLE attribute is specified, each
component-array-spec shall be a deferred-shape-spec-list.”
- “C442 (R436) If a coarray-spec appears, it shall be a
deferred-coshape-spec-list and the component shall have the ALLOCATABLE attribute.”
- “C443 (R436) If a coarray-spec appears, the component shall not be of type
C_PTR or C_FUNPTR.”
- “C445 (R436) If neither the POINTER nor the ALLOCATABLE attribute is
specified, each component-array-spec shall be an explicit-shape-spec-list.”
- “C447 (R436) A component shall not have both the ALLOCATABLE and POINTER
attributes.”
- “C448 (R436) If the CONTIGUOUS attribute is specified, the component shall
be an array with the POINTER attribute.”
- “C457 (R436) If component-initialization appears, a double-colon separator
shall appear before the component-decl-list.”
- “C458 (R436) If component-initialization appears, every type parameter and
array bound of the component shall be a colon or constant expression.
- “C459 (R436) If => appears in component-initialization, POINTER shall
appear in the component-attr-spec-list. If = appears in component-initialization, neither POINTER nor ALLOCATABLE shall appear in the component-attr-spec-list.”
C439-C443, C445, C447-C448, C457-C459 are currently not checked - issue #258.
- static match(string)[source]
Implements the matching of a data component definition statement.
- Parameters:
string (str) – the reader or string to match as a data component definition statement.
- Returns:
a 3-tuple containing declaration type specification, component attribute specification and component declaration list if there is a match or None if there is no match.
- Return type:
NoneType or (
fparser.two.Fortran2003.Declaration_Type_Spec
,fparser.two.Fortran2008.Component_Attr_Spec_List
,fparser.two.Fortran2003.Component_Decl_List
)
- class fparser.two.Fortran2008.Component_Attr_Spec(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Component_Attr_Spec
Fortran 2008 rule R437.
component-attr-spec is access-spec or ALLOCATABLE or CODIMENSION lbracket coarray-spec rbracket or CONTIGUOUS or DIMENSION ( component-array-spec ) or POINTER
In the spec above, lbracket and rbracket are left and right square brackets [] but not printed explicitly to avoid misinterpretation as optional parts.
This rule adds CODIMENSION and CONTIGUOUS attributes to Fortran2003’s R441.
- subclass_names
- attributes
- class fparser.two.Fortran2008.Type_Declaration_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Type_Declaration_Stmt
Fortran 2008 rule 501.
type-declaration-stmt is declaration-type-spec [ [ , attr-spec ] ... :: ] entity-decl-list
The implementation of this rule does not add anything to the Fortran 2003 variant but overwrites
get_attr_spec_list_cls()
to use the Fortran 2008 variant ofAttr_Spec_List
.Associated constraints are:
- “C501 (R501) The same attr-spec shall not appear more than once in a given
type-declaration-stmt.”
- “C502 (R501) If a language-binding-spec with a NAME= specifier appears,
the entity-decl-list shall consist of a single entity-decl.”
- “C503 (R501) If a language-binding-spec is specified, the entity-decl-list
shall not contain any procedure names.”
- “C505 (R501) If initialization appears, a double-colon separator shall
appear before the entity-decl-list.”
C501-C503, C505 are currently not checked - issue #259.
- class fparser.two.Fortran2008.Codimension_Attr_Spec(string, parent_cls=None)[source]
Bases:
fparser.two.utils.WORDClsBase
codimension-attr-spec is CODIMENSION lbracket coarray-spec rbracket
In the spec above, lbracket and rbracket are left and right square brackets [] but not printed explicitly to avoid misinterpretation as optional parts.
- subclass_names = []
- use_names = ['Coarray_Bracket_Spec']
- static match(string)[source]
Implements the matching for the CODIMENSION attribute.
- Parameters:
string (str) – the string to match as the attribute.
- Returns:
None if there is no match, otherwise a 2-tuple containing CODIMENSION as a string and the matched coarray-spec..
- Return type:
NoneType or (str,
fparser.two.Fortran2008.Coarray_Bracket_Spec
,)
- class fparser.two.Fortran2008.Coarray_Bracket_Spec(string, parent_cls=None)[source]
Bases:
fparser.two.utils.BracketBase
coarray-bracket-spec is lbracket coarray-spec rbracket
In the spec above, lbracket and rbracket are left and right square brackets [] but not printed explicitly to avoid misinterpretation as optional parts.
- subclass_names = []
- use_names = ['Coarray_Spec']
- static match(string)[source]
Implements the matching for the coarray specification including the square brackets.
- Parameters:
string (str) – the string to match as the specification.
- Returns:
None if there is no match, otherwise a 3-tuple containing the left bracket, the matched coarray-spec, and the right bracket.
- Return type:
NoneType or (str,
fparser.two.Fortran2008.Coarray_Spec
, str)
- class fparser.two.Fortran2008.Attr_Spec(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Attr_Spec
Fortran 2008 rule R502.
attr-spec is access-spec or ALLOCATABLE or ASYNCHRONOUS or CODIMENSION lbracket coarray-spec rbracket or CONTIGUOUS or DIMENSION ( array-spec ) or EXTERNAL or INTENT ( intent-spec ) or INTRINSIC or language-binding-spec or OPTIONAL or PARAMETER or POINTER or PROTECTED or SAVE or TARGET or VALUE or VOLATILE
In the spec above, lbracket and rbracket are left and right square brackets [] but not printed explicitly to avoid misinterpretation as optional parts.
This rule adds CODIMENSION and CONTIGUOUS attributes to Fortran2003’s R503.
- subclass_names
- use_names = []
- class fparser.two.Fortran2008.Coarray_Spec(string, parent_cls=None)[source]
Bases:
fparser.two.utils.Base
Fortran 2008 rule R509.
coarray-spec is deferred-coshape-spec-list or explicit-coshape-spec-list
- subclass_names = ['Explicit_Coshape_Spec', 'Deferred_Coshape_Spec_List']
- class fparser.two.Fortran2008.Deferred_Coshape_Spec(string, parent_cls=None)[source]
Bases:
fparser.two.utils.SeparatorBase
Fortran 2008 rule R510 deferred-coshape-spec is :
- subclass_names = []
- class fparser.two.Fortran2008.Explicit_Coshape_Spec(string, parent_cls=None)[source]
Bases:
fparser.two.utils.SeparatorBase
Fortran 2008 rule R511 explicit-coshape-spec is [ coshape-spec-list , ] [ lower-cobound : ] *
Associated constraint is:
- “C529 (R511) A lower-cobound or upper-cobound that is not a constant
expression shall appear only in a subprogram, BLOCK construct, or interface body.”
C529 is currently not checked - issue #259.
- subclass_names = []
- use_names = ['Coshape_Spec_List', 'Lower_Cobound']
- static match(string)[source]
Implements the matching for explicit coarray shape specification.
- Parameters:
string (str) – the string to match as deferred shape.
- Returns:
None if there is no match, otherwise a 2-tuple containing matched coshape-spec-list or None and matched lower-cobound or None.
- Return type:
NoneType or (
fparser.two.Fortran2008.Coshape_Spec_List
or None,fparser.two:Fortran2008.Lower_Cobound
or None)
- class fparser.two.Fortran2008.Coshape_Spec(string, parent_cls=None)[source]
Bases:
fparser.two.utils.SeparatorBase
coshape-spec is [ lower-cobound : ] upper-cobound
- subclass_names = []
- use_names = ['Lower_Cobound', 'Upper_Cobound']
- static match(string)[source]
Implements the matching for a coarray shape.
- Parameters:
string (str) – the string to match as shape.
- Returns:
None if there is no match, otherwise a 2-tuple with lower bound if given or None, and upper bound.
- Return type:
NoneType or (None,
fparser.two.Fortran2008.Upper_Cobound
) or (fparser.two.Fortran2008.Lower_Cobound
,fparser.two.Fortran2008.Upper_Cobound
)
- class fparser.two.Fortran2008.Lower_Cobound(string, parent_cls=None)[source]
Bases:
fparser.two.utils.Base
Fortran 2008 rule R512 lower-cobound is specification-expr
- subclass_names = ['Specification_Expr']
- class fparser.two.Fortran2008.Upper_Cobound(string, parent_cls=None)[source]
Bases:
fparser.two.utils.Base
Fortran 2008 rule R513 upper-cobound is specification-expr
- subclass_names = ['Specification_Expr']
- class fparser.two.Fortran2008.Do_Term_Action_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Do_Term_Action_Stmt
Fortran 2008 rule R826.
do-term-action-stmt is action-stmt
Associated constraints are:
- “C816 (R826) A do-term-action-stmt shall not be an arithmetic-if-stmt,
continue-stmt, cycle-stmt, end-function-stmt, end-mp-subprogram-stmt, end-program-stmt, end-subroutine-stmt, error-stop-stmt, exit-stmt, goto-stmt, return-stmt, or stop-stmt.”
- subclass_names = ['Action_Stmt_C816']
- class fparser.two.Fortran2008.Alloc_Opt(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Alloc_Opt
Fortran2008 rule R627.
alloc-opt is ERRMSG = errmsg-variable or MOLD = source-expr or SOURCE = source-expr or STAT = stat-variable
Extends the Fortran2003 version of this class by updating the keyword pairs (used in match) with support for MOLD.
- _keyword_pairs = [('STAT',), ('ERRMSG',), ('SOURCE',), ('MOLD',)]
- class fparser.two.Fortran2008.Allocate_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Allocate_Stmt
Fortran 2008 rule R626.
allocate-stmt is ALLOCATE ( [ type-spec :: ] allocation-list [, alloc-opt-list ] )
The implementation of this rule simply ensures that the Fortran2008 version of Alloc_Opt is used.
- subclass_names = []
- use_names = ['Type_Spec', 'Allocation_List', 'Alloc_Opt_List']
- class fparser.two.Fortran2008.Loop_Control(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Loop_Control
Fortran 2008 rule R818
- loop-control is [ , ] do-variable = scalar-int-expr , scalar-int-expr
[ , scalar-int-expr ]
or [ , ] WHILE ( scalar-logical-expr ) or [ , ] CONCURRENT forall-header
Extends the Fortran2003 rule R830 with the additional CONCURRENT clause.
The F2003 Loop_Control class would be better and more extensible if it called 2 classes, one for each of the above expressions. This would then affect the implementation of this class. Something like the suggestion below. However, this would result in a different fparser tree, see issue #416.
F2003: While_Loop_Cntl: scalar-logical-expression, delim F2003: Counter_Loop_Cntl: var, lower, upper, [step], delim F2008: Concurrent_Loop_Cntl: conc_expr, delim F2018: Concurrent_Loop_Cntl: conc_expr, local_x, delim
- subclass_names = []
- use_names
- static match(string)[source]
Attempts to match the supplied text with this rule.
- Parameters:
string (str) – Fortran code to check for a match.
- Returns:
None if there is no match, a tuple with the first entry providing the result of matching the ‘WHILE’ part of the rule if there is a match, the second entry providing the result of matching the ‘COUNTER’ part of the rule if there is a match, the third entry indicating whether there is an optional preceding ‘,’ and the fourth entry providing the result of matching the ‘CONCURRENT’ part of the rule if there is a match.
- Return type:
Optional[Tuple[ Optional[
fparser.two.Fortran2003.Scalar_Logical_Expr
], Optional[Tuple[fparser.two.Fortran2003.Do_Variable
, List[str]]], Optional[str], Optional[fparser.two.Fortran2003.Forall_Header
]]]
- class fparser.two.Fortran2008.If_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.If_Stmt
Fortran 2008 rule R837 if-stmt is IF ( scalar-logical-expr ) action-stmt
The implementation of this rule only replaces the
use_names
andaction_stmt_class
attributes to use the Fortran 2008 variantAction_Stmt_C828
instead offparser.two.Fortran2003.Action_Stmt_C802
.Associated constraints are:
- C828 (R837) The action-stmt in the if-stmt shall not be an end-function-stmt,
end-mp-subprogram-stmt, end-program-stmt, end-subroutine-stmt, or if-stmt.
- use_names = ['Scalar_Logical_Expr', 'Action_Stmt_C828']
- action_stmt_cls
- class fparser.two.Fortran2008.Error_Stop_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.utils.StmtBase
,fparser.two.utils.WORDClsBase
Fortran 2008 rule R856 error-stop-stmt is ERROR STOP [ stop-code ]
- subclass_names = []
- use_names = ['Stop_Code']
- static match(string)[source]
Check whether the input matches the rule
- Parameters:
string (str) – Text that we are trying to match.
- Returns:
None if there is no match or, if there is a match, a 2-tuple containing a string matching ‘ERROR STOP’ and an instance of
fparser.two.Fortran2003.Stop_Code
(or None if an instance of ‘Stop_Code’ is not required and not provided).- Return type:
(str,
fparser.two.Fortran2003.Stop_Code
or None) or NoneType
- class fparser.two.Fortran2008.Specification_Part_C1112(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Specification_Part
Fortran 2008 constraint C1112 C1112 A submodule specification-part shall not contain a format-stmt, entry-stmt, or stmt-function-stmt.
These statements are found in the following rule hierarchy
- format-stmt Specification_Part/implicit_part/implicit_part_stmt/format_stmt
Specification_Part/declaration_construct/format_stmt
- entry-stmt Specification_Part/implicit_part/implicit_part_stmt/entry_stmt
Specification_Part/declaration_construct/entry_stmt
- stmt-function-stmt Specification_Part/declaration_construct/
stmt-function-stmt
Therefore we need to specialise implicit_part, implicit_part_stmt and declaration_construct
- use_names = ['Use_Stmt', 'Import_Stmt', 'Implicit_Part_C1112', 'Declaration_Construct_C1112']
- static match(reader)[source]
Check whether the input matches the rule
- param reader: the fortran file reader containing the line(s)
of code that we are trying to match
- Returns:
tuple containing a single list which contains instance of the classes that have matched if there is a match or None if there is no match
- Return type:
Optional[Tuple[List[
fparser.two.utils.Base
]]]
- class fparser.two.Fortran2008.Implicit_Part_C1112(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Implicit_Part
Fortran 2008 constraint C1112 C1112 A submodule specification-part shall not contain a format-stmt, entry-stmt, or stmt-function-stmt.
This class specialises ‘Implicit_Part’ so that the specialised ‘Implicit_Part_Stmt_C1112’ is called rather than the original ‘Implicit_Part_Stmt’
- use_names = ['Implicit_Part_Stmt_C1112', 'Implicit_Stmt']
- static match(reader)[source]
Check whether the input matches the rule
- param reader: the fortran file reader containing the line(s)
of code that we are trying to match
- Returns:
tuple containing a single list which contains instance of the classes that have matched if there is a match or None if there is no match
- class fparser.two.Fortran2008.Implicit_Part_Stmt_C1112(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Implicit_Part_Stmt
Fortran 2008 constraint C1112 C1112 A submodule specification-part shall not contain a format-stmt, entry-stmt, or stmt-function-stmt.
This class specialises ‘Implicit_Part_Stmt’ to remove ‘Format_Stmt’ and ‘Entry_Stmt’
- subclass_names
- class fparser.two.Fortran2008.Declaration_Construct_C1112(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Declaration_Construct
Fortran 2008 constraint C1112 C1112 A submodule specification-part shall not contain a format-stmt, entry-stmt, or stmt-function-stmt.
This class specialises ‘Declaration_Construct’ to remove ‘Format_Stmt’, ‘Entry_Stmt’ and ‘Stmt_Function_Stmt’
- subclass_names
- class fparser.two.Fortran2008.Submodule(string, parent_cls=None)[source]
Bases:
fparser.two.utils.BlockBase
Fortran 2008 rule R1116.
submodule is submodule-stmt [ specification-part ] [ module-subprogram-part ] end-submodule-stmt
C1112 A submodule specification-part shall not contain a format-stmt, entry-stmt, or stmt-function-stmt. This constraint is handled by specialising the Specification_Part class.
C1114 If a submodule-name appears in the end-submodule-stmt, it shall be identical to the one in the submodule-stmt. This constraint is handled by the Base class with the names being provided by the ‘Submodule_Stmt and ‘End_Submodule_Stmt’ classes via a get_name method.
- subclass_names = []
- use_names = ['Submodule_Stmt', 'Specification_Part_C1112', 'Module_Subprogram_Part', 'End_Submodule_Stmt']
- static match(reader)[source]
Check whether the input matches the rule
- param reader: the fortran file reader containing the line(s)
of code that we are trying to match
- Returns:
tuple containing a single list which contains instance of the classes that have matched if there is a match or None if there is no match
- class fparser.two.Fortran2008.Submodule_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.utils.Base
,fparser.two.utils.ScopingRegionMixin
Fortran 2008 rule R1117:
submodule-stmt is SUBMODULE ( parent-identifier ) submodule-name
- subclass_names = []
- use_names = ['Submodule_Name', 'Parent_Identifier']
- static match(fstring)[source]
Check whether the input matches the rule
- Parameters:
fstring (st) – contains the Fortran that we are trying to match.
- Returns:
instances of the Classes that have matched if there is a match or None if there is no match.
- Return type:
Optional[Tuple[
fparser.two.Fortran2008.Parent_Identifier
,fparser.two.Fortran2008.Submodule_Name
]]
- class fparser.two.Fortran2008.End_Submodule_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.utils.EndStmtBase
Fortran 2008 rule R1119 end-submodule-stmt is END [ SUBMODULE [ submodule-name ] ]
- subclass_names = []
- use_names = ['Submodule_Name']
- static match(fstring)[source]
Check whether the input matches the rule
param string fstring : contains the Fortran that we are trying to match
- Returns:
instances of the Classes that have matched if there
is a match or None if there is no match
- get_name()[source]
Fortran 2008 constraint C1114 return the submodule name as specified by the end submodule statement or None if one is not specified. This is used by the base class to check whether this name matches the submodule name.
- Returns:
the name of the submodule stored in a Name class
- Return type:
fparser.two.Fortran2003.Name
or None
- class fparser.two.Fortran2008.Parent_Identifier(string, parent_cls=None)[source]
Bases:
fparser.two.utils.Base
Fortran 2008 rule R1118 parent-identifier is ancestor-module-name [ : parent-submodule-name ]
C1113 The ancestor-module-name shall be the name of a nonintrinsic module; the parent-submodule name shall be the name of a descendant of that module. This constraint can not be tested by fparser in general as the module or submodule may be in a different file. We therefore do not check this constraint in fparser.
- use_names = ['Ancestor_Module_Name', 'Parent_SubModule_Name']
- class fparser.two.Fortran2008.Open_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Open_Stmt
Fortran2008 Rule R904.
open-stmt is OPEN ( connect-spec-list )
- subclass_names = []
- use_names = ['Connect_Spec_List']
- class fparser.two.Fortran2008.Connect_Spec(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Connect_Spec
Fortran2008 rule R905. Extends the Fortran2003 definition with support for the NEWUNIT specifier.
- connect-spec is [ UNIT = ] file-unit-number
or ACCESS = scalar-default-char-expr or ACTION = scalar-default-char-expr or ASYNCHRONOUS = scalar-default-char-expr or BLANK = scalar-default-char-expr or DECIMAL = scalar-default-char-expr or DELIM = scalar-default-char-expr or ENCODING = scalar-default-char-expr or ERR = label or FILE = file-name-expr or FORM = scalar-default-char-expr or IOMSG = iomsg-variable or IOSTAT = scalar-int-variable or NEWUNIT = scalar-int-variable or PAD = scalar-default-char-expr or POSITION = scalar-default-char-expr or RECL = scalar-int-expr or ROUND = scalar-default-char-expr or SIGN = scalar-default-char-expr or STATUS = scalar-default-char-expr
R906 file-name-expr is scalar-default-char-expr R907 iomsg-variable is scalar-default-char-variable C903 No specifier shall appear more than once in a given connect-spec-list.
- C904 (R904) If the NEWUNIT= specifier does not appear, a file-unit-number
shall be specified; if the optional characters UNIT= are omitted, the file-unit-number shall be the first item in the connect-spec-list.
- C905 (R904) The label used in the ERR= specifier shall be the statement label
of a branch target statement that appears in the same inclusive scope as the OPEN statement.
- C906 (R904) If a NEWUNIT= specifier appears, a file-unit-number shall not
appear.
The constraints listed above are checked for in the Open_Stmt.match() method as we don’t have access to the full list of Connect_Spec elements here. The exceptions are the second part of C904 (un-named file-unit-number must be first in the list) and C905: these are not currently checked.
- subclass_names = []
- use_names = ['File_Unit_Number', 'Scalar_Default_Char_Expr', 'Label', 'File_Name_Expr', 'Iomsg_Variable',...
- class fparser.two.Fortran2008.Block_Construct(string, parent_cls=None)[source]
Bases:
fparser.two.utils.BlockBase
Fortran 2008 Rule 807.
- block-construct is block-stmt
[ specification-part ] block end-block-stmt
TODO #394: Should disallow COMMON, EQUIVALENCE, IMPLICIT, INTENT, NAMELIST, OPTIONAL, VALUE, and statement functions (C806) (which are all valid members of Specification_Part).
- subclass_names = []
- use_names = ['Block_Stmt', 'Specification_Part', 'Execution_Part_Construct', 'End_Block_Stmt']
- static match(reader)[source]
Checks whether the content in reader matches the given type of block statement (e.g. DO..END DO, IF…END IF etc.)
- Parameters:
startcls (type) – the class marking the beginning of the block
subclasses (list) – list of classes that can be children of the block.
endcls (type) – the class marking the end of the block.
reader (str or instance of
FortranReaderBase
) – content to check for match.match_labels (bool) – whether or not the statement terminating the block must have a label that matches the opening statement. Default is False.
match_names (bool) – TBD
match_name_classes (tuple) – TBD
enable_do_label_construct_hook (bool) – TBD
enable_if_construct_hook (bool) – TBD
enable_where_construct_hook (bool) – TBD
strict_order (bool) – whether to enforce the order of the given subclasses.
strict_match_names (bool) – if start name present, end name must exist and match.
- Returns:
instance of startcls or None if no match is found
- Return type:
startcls
- class fparser.two.Fortran2008.Block_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.utils.StmtBase
,fparser.two.utils.WORDClsBase
,fparser.two.utils.ScopingRegionMixin
Fortran 2008 Rule 808.
block-stmt is [ block-construct-name : ] BLOCK
- subclass_names = []
- use_names = ['Block_Construct_Name']
- counter = 0
- static match(string)[source]
Attempts to match the supplied text with this rule.
- Parameters:
string (str) – the text to match.
- Returns:
a tuple of the matched node and instance of Counter or None if there is no match.
- Return type:
Tuple[“BLOCK”,
fparser.two.Fortran2008.Block_Stmt.Counter
] | NoneType
- class fparser.two.Fortran2008.End_Block_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.utils.EndStmtBase
Fortran 2008 Rule 809.
end-block-stmt is END BLOCK [ block-construct-name ]
- subclass_names = []
- use_names = ['Block_Construct_Name']
- class fparser.two.Fortran2008.Critical_Construct(string, parent_cls=None)[source]
Bases:
fparser.two.utils.BlockBase
Fortran 2008 Rule 810.
- critical-construct is critical-stmt
block end-critical-stmt
TODO: Should disallow RETURN (C809) and CYCLE or EXIT to outside block (C811)
- subclass_names = []
- use_names = ['Critical_Stmt', 'Execution_Part_Construct', 'End_Critical_Stmt']
- static match(reader)[source]
Attempt to match the supplied content with this Rule.
- Parameters:
reader (
fparser.common.readfortran.FortranFileReader
|fparser.common.readfortran.FortranStringReader
) – the fortran file reader containing the line(s) of code that we are trying to match- Returns:
instance of class that has matched or None if no match.
- Return type:
fparser.two.utils.BlockBase
| NoneType
- class fparser.two.Fortran2008.Critical_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.utils.StmtBase
,fparser.two.utils.WORDClsBase
Fortran 2008 Rule R811.
critical-stmt is [ critical-construct-name : ] CRITICAL
- subclass_names = []
- use_names = ['Critical_Construct_Name']
- class fparser.two.Fortran2008.End_Critical_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.utils.EndStmtBase
Fortran 2008 Rule 812.
end-critical-stmt is END CRITICAL [ critical-construct-name ]
- subclass_names = []
- use_names = ['Critical_Construct_Name']
- class fparser.two.Fortran2008.Procedure_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Procedure_Stmt
Fortran 2008 Rule 1206.
procedure-stmt is [ MODULE ] PROCEDURE [ :: ] procedure-name-list
- static match(string)[source]
- Parameters:
string (str) – Fortran code to check for a match
- Returns:
3-tuple containing a boolean indicating whether the optional MODULE keyword is included, a boolean indicating whether the optional ‘::’ is included and a Procedure_Name_List instance, or None if there is no match.
- Return type:
Optional[Tuple[ bool, bool,
fparser.two.Fortran2003.Procedure_Name_List
]]]
- class fparser.two.Fortran2008.Action_Term_Do_Construct(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Action_Term_Do_Construct
Subclass the 2003 version so that this class will import the Fortran2008 Label_Do_Stmt class.
- class fparser.two.Fortran2008.Block_Label_Do_Construct(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Block_Label_Do_Construct
Subclass the 2003 version so that this class will import the Fortran2008 Label_Do_Stmt class
- class fparser.two.Fortran2008.Block_Nonlabel_Do_Construct(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Block_Nonlabel_Do_Construct
Subclass the 2003 version so that this class will import the Fortran2008 Nonlabel_Do_Stmt class
- class fparser.two.Fortran2008.Label_Do_Stmt(string, parent_cls=None)[source]
Bases:
fparser.two.Fortran2003.Label_Do_Stmt
Subclass the 2003 version so that this class will import the Fortran2008 Label_Do_Stmt class.