[Python-modules-commits] [fparser] 05/05: WIP: adding Fortran 2015 support
Alastair McKinstry
mckinstry at moszumanska.debian.org
Fri Jul 28 10:45:44 UTC 2017
This is an automated email from the git hooks/post-receive script.
mckinstry pushed a commit to branch dev-f2015
in repository fparser.
commit d79442392c6902a5b3cc748f3c2f280fba9bedd1
Author: Alastair McKinstry <mckinstry at debian.org>
Date: Fri Jul 28 11:43:39 2017 +0100
WIP: adding Fortran 2015 support
---
src/fparser/Fortran2015.py | 448 ++++++++++++++++++++++++++++------
src/fparser/tests/test_Fortran2015.py | 11 +
2 files changed, 382 insertions(+), 77 deletions(-)
diff --git a/src/fparser/Fortran2015.py b/src/fparser/Fortran2015.py
index 0694757..ac49401 100644
--- a/src/fparser/Fortran2015.py
+++ b/src/fparser/Fortran2015.py
@@ -617,12 +617,12 @@ class NumberBase(Base):
::
<number-base> = <number> [ _ <kind-param> ]
"""
+ @staticmethod
def match(number_pattern, string):
m = number_pattern.match(string.replace(' ',''))
if m is None: return
d = m.groupdict()
return d['value'].upper(),d.get('kind_param')
- match = staticmethod(match)
def tostr(self):
if self.items[1] is None: return str(self.items[0])
return '%s_%s' % tuple(self.items)
@@ -634,6 +634,7 @@ class CallBase(Base):
::
<call-base> = <lhs> ( [ <rhs> ] )
"""
+ @staticmethod
def match(lhs_cls, rhs_cls, string, upper_lhs = False, require_rhs=False):
if not string.endswith(')'): return
line, repmap = string_replace_map(string)
@@ -662,7 +663,6 @@ class CallBase(Base):
elif require_rhs:
return
return lhs, None
- match = staticmethod(match)
def tostr(self):
if self.items[1] is None: return '%s()' % (self.items[0])
return '%s(%s)' % (self.items[0], self.items[1])
@@ -672,9 +672,9 @@ class CALLBase(CallBase):
::
<CALL-base> = <LHS> ( [ <rhs> ] )
"""
+ @staticmethod
def match(lhs_cls, rhs_cls, string, require_rhs = False):
return CallBase.match(lhs_cls, rhs_cls, string, upper_lhs=True, require_rhs = require_rhs)
- match = staticmethod(match)
class StringBase(Base):
"""
@@ -685,6 +685,7 @@ Attributes
----------
string
"""
+ @staticmethod
def match(pattern, string):
if isinstance(pattern, (list,tuple)):
for p in pattern:
@@ -696,7 +697,6 @@ string
return
if pattern.match(string): return string,
return
- match = staticmethod(match)
def init(self, string):
self.string = string
return
@@ -711,6 +711,7 @@ class STRINGBase(StringBase):
<STRING-base> = <XYZ>
"""
match = staticmethod(StringBase.match)
+ @staticmethod
def match(pattern, string):
if isinstance(pattern, (list,tuple)):
for p in pattern:
@@ -723,7 +724,6 @@ class STRINGBase(StringBase):
return
if pattern.match(STRING): return STRING,
return
- match = staticmethod(match)
class StmtBase(Base):
"""
@@ -948,9 +948,10 @@ class Program_Unit(Base): # R202
<program-unit> = <main-program>
| <external-subprogram>
| <module>
+ | <submodule>
| <block-data>
"""
- subclass_names = ['Main_Program', 'External_Subprogram', 'Module', 'Block_Data']
+ subclass_names = ['Main_Program', 'External_Subprogram', 'Module', 'Submodule', 'Block_Data']
class External_Subprogram(Base): # R203
"""
@@ -1015,9 +1016,26 @@ class Declaration_Construct(Base): # R207
'Interface_Block', 'Parameter_Stmt', 'Procedure_Declaration_Stmt',
'Specification_Stmt', 'Type_Declaration_Stmt', 'Stmt_Function_Stmt']
-class Execution_Part(BlockBase): # R208
+class Specification_Construct(Base): #R208
+ """
+:F08R:`208`::
+ <specification-construct> = <derived-type-def>
+ | <enum-def>
+ | <generic-stmt>
+ | <interface-block>
+ | <parameter-stmt>
+ | <procedure-declaration-stmt>
+ | <other-specification-stmt>
+ | <type-declaration-stmt>
+ """
+ subclass_names = ['Derived_Type_Def', 'Enum_Def', 'Generic_Stmt', 'Interface_Block', 'Paremeter_Stmt',
+ 'Procedure_Declaration_Stmt', 'Other_Specification_Stmt', 'Type_Declaration_Stmt' ]
+
+
+class Execution_Part(BlockBase): # R209
"""
:F03R:`208`::
+:F08R:`209`::
<execution-part> = <executable-construct>
| [ <execution-part-construct> ]...
@@ -1025,11 +1043,14 @@ class Execution_Part(BlockBase): # R208
"""
subclass_names = []
use_names = ['Executable_Construct_C201', 'Execution_Part_Construct_C201']
- def match(string): return BlockBase.match(Executable_Construct_C201, [Execution_Part_Construct_C201], None, string)
- match = staticmethod(match)
+ @staticmethod
+ def match(string):
+ return BlockBase.match(Executable_Construct_C201, [Execution_Part_Construct_C201], None, string)
-class Execution_Part_Construct(Base): # R209
+class Execution_Part_Construct(Base): # R210
"""
+:F03R:`209`::
+:F08R:`210`::
<execution-part-construct> = <executable-construct>
| <format-stmt>
| <entry-stmt>
@@ -1040,8 +1061,9 @@ class Execution_Part_Construct(Base): # R209
class Execution_Part_Construct_C201(Base):
subclass_names = ['Executable_Construct_C201', 'Format_Stmt', 'Entry_Stmt', 'Data_Stmt']
-class Internal_Subprogram_Part(BlockBase): # R210
+class Internal_Subprogram_Part(BlockBase): # R211
"""
+:F08R:`211`::
<internal-subprogram-part> = <contains-stmt>
<internal-subprogram>
[ <internal-subprogram> ]...
@@ -1052,8 +1074,9 @@ class Internal_Subprogram_Part(BlockBase): # R210
def match(reader):
return BlockBase.match(Contains_Stmt, [Internal_Subprogram], None, reader)
-class Internal_Subprogram(Base): # R211
+class Internal_Subprogram(Base): # R212
"""
+:F08R:`212`
<internal-subprogram> = <function-subprogram>
| <subroutine-subprogram>
"""
@@ -1087,27 +1110,68 @@ class Specification_Stmt(Base):# R212
'Optional_Stmt','Pointer_Stmt','Protected_Stmt','Save_Stmt',
'Target_Stmt','Volatile_Stmt', 'Value_Stmt']
-class Executable_Construct(Base):# R213
+
+class Other_Specification_Stmt(Base): #R213
+ """
+:F08R:`213`::
+ <other-specification-stmt> = <access-stmt>
+ | <allocatable-stmt>
+ | <asynchronous-stmt>
+ | <bind-stmt>
+ | <codimension-stmt>
+ | <contiguous-stmt>
+ | <dimension-stmt>
+ | <external-stmt>
+ | <intent-stmt>
+ | <intrinsic-stmt>
+ | <namelist-stmt>
+ | <optional-stmt>
+ | <pointer-stmt>
+ | <protected-stmt>
+ | <save-stmt>
+ | <target-stmt>
+ | <volatile-stmt>
+ | <value-stmt>
+ | <common-stmt>
+ | <equivalence-stmt>
"""
+ subclass_names = ['Access_Stmt', 'Allocatable_Stmt', 'Asynchronous_Stmt','Bind_Stmt',
+ 'Codimension_Stmt', 'Contiguous_Stmt', 'Dimension_Stmt',
+ 'External_Stmt', 'Intent_Stmt', 'Intrinsic_Stmt', 'Namelist_Stmt',
+ 'Optional_Stmt','Pointer_Stmt','Protected_Stmt','Save_Stmt',
+ 'Target_Stmt','Volatile_Stmt', 'Value_Stmt',
+ 'Common_Stmt', 'Equivalence_Stmt' ]
+
+
+class Executable_Construct(Base): # R214
+ """
+:F03R:`213`::
+:F08R:`214`::
<executable-construct> = <action-stmt>
| <associate-stmt>
+ | <block-construct>
| <case-construct>
+ | <critical-construct>
| <do-construct>
- | <forall-construct>
| <if-construct>
+ | <select-rank-construct>
| <select-type-construct>
| <where-construct>
+ | <forall-construct>
"""
- subclass_names = ['Action_Stmt', 'Associate_Stmt', 'Case_Construct', 'Do_Construct',
- 'Forall_Construct', 'If_Construct', 'Select_Type_Construct', 'Where_Construct']
+ subclass_names = ['Action_Stmt', 'Associate_Stmt', 'Block_Construct', 'Case_Construct', 'Critical_Construct',
+ 'Do_Construct', 'If_Construct', 'Select_Rank_Construct', 'Select_Type_Construct',
+ 'Where_Construct', 'Forall_Construct']
class Executable_Construct_C201(Base):
subclass_names = Executable_Construct.subclass_names[:]
subclass_names[subclass_names.index('Action_Stmt')] = 'Action_Stmt_C201'
-class Action_Stmt(Base):# R214
+class Action_Stmt(Base):# R215
"""
+:F03R:`214`::
+:F08R:`215`::
<action-stmt> = <allocate-stmt>
| <assignment-stmt>
| <backspace-stmt>
@@ -1118,14 +1182,19 @@ class Action_Stmt(Base):# R214
| <deallocate-stmt>
| <endfile-stmt>
| <end-function-stmt>
+ | <end-mp-subprogram-stmt>
| <end-program-stmt>
| <end-subroutine-stmt>
+ | <endfile-stmt>
+ | <error-stop-stmt>
+ | <event-post-stmt>
+ | <event-wait-stmt>
| <exit-stmt>
| <flush-stmt>
- | <forall-stmt>
| <goto-stmt>
| <if-stmt>
| <inquire-stmt>
+ | <lock-stmt>
| <nullify-stmt>
| <open-stmt>
| <pointer-assignment-stmt>
@@ -1134,18 +1203,29 @@ class Action_Stmt(Base):# R214
| <return-stmt>
| <rewind-stmt>
| <stop-stmt>
+ | <sync-all-stmt>
+ | <sync-images-stmt>
+ | <sync-memory-stmt>
+ | <unlock-stmt>
| <wait-stmt>
| <where-stmt>
| <write-stmt>
| <arithmetic-if-stmt>
| <computed-goto-stmt>
+ | <forall-stmt>
"""
+ # TODO: <arithmetic-if-stmt> removed in Fortran2008.
+ # Need to add code to handle removed stuff.
+
subclass_names = ['Allocate_Stmt', 'Assignment_Stmt', 'Backspace_Stmt', 'Call_Stmt',
'Close_Stmt', 'Continue_Stmt', 'Cycle_Stmt', 'Deallocate_Stmt',
- 'Endfile_Stmt', 'End_Function_Stmt', 'End_Subroutine_Stmt', 'Exit_Stmt',
- 'Flush_Stmt', 'Forall_Stmt', 'Goto_Stmt', 'If_Stmt', 'Inquire_Stmt',
+ 'Endfile_Stmt', 'End_Function_Stmt', 'End_MP_Subprogram_Stmt', 'End_Program_Stmt',
+ 'End_Subroutine_Stmt', 'Endfile_Stmt', 'Error_Stop_Stmt', 'Event_Post_Stmt',
+ 'Event_Wait_Stmt', 'Exit_Stmt',
+ 'Flush_Stmt', 'Forall_Stmt', 'Goto_Stmt', 'If_Stmt', 'Inquire_Stmt', 'Lock_Stmt',
'Nullify_Stmt', 'Open_Stmt', 'Pointer_Assignment_Stmt', 'Print_Stmt',
- 'Read_Stmt', 'Return_Stmt', 'Rewind_Stmt', 'Stop_Stmt', 'Wait_Stmt',
+ 'Read_Stmt', 'Return_Stmt', 'Rewind_Stmt', 'Stop_Stmt',
+ 'Sync_All_Stmt', 'Sync_Images_Stmt', 'Sync_Memory_Stmt', 'Unlock_Stmt', 'Wait_Stmt',
'Where_Stmt', 'Write_Stmt', 'Arithmetic_If_Stmt', 'Computed_Goto_Stmt']
class Action_Stmt_C201(Base):
@@ -1268,25 +1348,39 @@ string : str
############################### SECTION 4 ####################################
###############################################################################
-class Type_Spec(Base): # R401
+class Type_Param_Value(StringBase): # R401
+ """
+ <type-param-value> = <scalar-int-expr>
+ | *
+ | :
+ """
+ subclass_names = ['Scalar_Int_Expr']
+ use_names = []
+ @staticmethod
+ def match(string):
+ return StringBase.match(['*',':'], string)
+
+class Type_Spec(Base): # R402
"""
<type-spec> = <intrinsic-type-spec>
| <derived-type-spec>
"""
subclass_names = ['Intrinsic_Type_Spec', 'Derived_Type_Spec']
-class Type_Param_Value(StringBase): # R402
+
+class Declaration_Type_Spec(WORDClsBase): #R403
"""
- <type-param-value> = <scalar-int-expr>
- | *
- | :
+ <declaration-type-spec> = <intrinsic-type-spec>
+ | TYPE ( <intrinsic-type-spec> )
+ | TYPE ( <derived-type-spec> )
+ | CLASS ( <derived-type-spec> )
+ | CLASS ( * )
+ | TYPE ( * )
"""
- subclass_names = ['Scalar_Int_Expr']
- use_names = []
- def match(string): return StringBase.match(['*',':'], string)
- match = staticmethod(match)
+ # TODO
+ pass
-class Intrinsic_Type_Spec(WORDClsBase): # R403
+class Intrinsic_Type_Spec(WORDClsBase): # R403?
"""
<intrinsic-type-spec> = INTEGER [ <kind-selector> ]
| REAL [ <kind-selector> ]
@@ -2304,6 +2398,53 @@ class Ac_Do_Variable(Base): # R472
############################### SECTION 5 ####################################
###############################################################################
+class Change_Team_Construct(BlockBase): #R501
+ """
+ <change-team-construct> = <change-team-stmt>
+ <block>
+ <end-change-team-stmt>
+ """
+ subclass_names = [ 'Change_Team_Stmt', 'Block', 'End_Change_Team_Stmt' ]
+ # TODO
+
+class Change_Team_Stmt(StmtBase): # R502
+ """
+ <change-team-stmt> = [ <team-construct-name> ]: CHANGE TEAM ( <team-variable>
+ [ , <coarray-association-list> ] [, <sync-stat-list> ] )
+
+ """
+ # TODO
+ pass
+
+class Coarray_Association(BinaryOpBase): #R503
+ """
+ <codimension-decl> => <coselector-name
+ """
+ subclass_names = []
+ use_names = [ 'Codimension_Decl', 'Coselector_Name' ]
+ @staticmethod
+ def match(string):
+ return BinaryOpBase.match(Codimension_Decl, '=>', Coselector_Name, string)
+
+class End_Change_Team_Stmt(EndStmtBase): #R504
+ """
+ <end-change-team-stmt> = END TEAM [ ( <sync-stat-list>) ] [ <team-construct-name> ]
+ """
+ # TODO: NEED TO HANDLE <sync-stat-list>
+ subclass_names = []
+ use_names = [ 'Sync_Stat_List', 'Change_Team_Construct_Name' ]
+ @staticmethod
+ def match(string):
+ return EndStmtBase.match('CHANGE TEAM',Change_Team_Construct_Name, string, require_stmt_type=True)
+
+
+class Team_Variable(Base): #R505
+ """
+ <team-variable> = [ <scalar-variable> ]
+ """
+ subclass_names = [ 'Scalar_Variable' ]
+
+
class Type_Declaration_Stmt(Type_Declaration_StmtBase): # R501
"""
<type-declaration-stmt> = <declaration-type-spec> [ [ , <attr-spec> ]... :: ] <entity-decl-list>
@@ -2485,6 +2626,16 @@ class Object_Name(Base): # R505
"""
subclass_names = ['Name']
+class Form_Team_Stmt(StmtBase): # R506 in F2015
+ """
+ <form-team-stmt> = FORM TEAM ( <team-number>, <team-variable> [ , <form-team-spec-list> ])
+ """
+ # TODO
+ subclass_names = []
+ use_names = [ 'Team_Number', 'Team_Variable', 'Form_Team_Spec_list' ]
+
+
+
class Initialization(Base): # R506
"""
<initialization> = = <initialization-expr>
@@ -2500,8 +2651,8 @@ class Initialization(Base): # R506
return
match = staticmethod(match)
def tostr(self): return '%s %s' % self.items
-
-class Team_Number(Base): # R507
+
+class Team_Number(Base): # R507 (F2015)
"""
<team-number> = <scalar-int-expr>
"""
@@ -2514,9 +2665,20 @@ class Null_Init(STRINGBase): # R507
<function-reference> shall be a reference to the NULL intrinsic function with no arguments.
"""
subclass_names = ['Function_Reference']
- def match(string): return STRINGBase.match('NULL', string)
- match = staticmethod(match)
+ @staticmethod
+ def match(string):
+ return STRINGBase.match('NULL', string)
+
+class Form_Team_Spec(Base): # R508
+ """
+ <form-team-spec> = NEW INDEX = <scalar-int-expr>
+ | <sync-stat>
+ """
+ subclass_names = []
+ use_names = [ 'Scalar_Int_Expr', 'Sync_Stat' ]
+ # TODO
+
class Access_Spec(STRINGBase): # R508
"""
:F03R:`508`::
@@ -2527,6 +2689,15 @@ class Access_Spec(STRINGBase): # R508
def match(string): return STRINGBase.match(['PUBLIC','PRIVATE'], string)
match = staticmethod(match)
+class Sync_Team_Stmt(StmtBase): #R509 in F2015
+ """
+:F15D:`509`::
+ <sync-team-stmt> = SYNC TEAM ( <team-variable> [, <sync-stat-list>])
+ """
+ subclass_names = []
+ use_names = [ 'Team_Variable', 'Sync_Stat_List' ]
+ # TODO
+
class Language_Binding_Spec(Base): # R509
"""
:F03R:`509`::
@@ -2669,8 +2840,9 @@ class Access_Stmt(StmtBase, WORDClsBase): # R518
"""
subclass_names = []
use_names = ['Access_Spec', 'Access_Id_List']
- def match(string): return WORDClsBase.match(['PUBLIC', 'PRIVATE'],Access_Id_List,string,check_colons=True, require_cls=False)
- match = staticmethod(match)
+ @staticmethod
+ def match(string):
+ return WORDClsBase.match(['PUBLIC', 'PRIVATE'],Access_Id_List,string,check_colons=True, require_cls=False)
tostr = WORDClsBase.tostr_a
class Access_Id(Base): # R519
@@ -2697,10 +2869,10 @@ class Allocatable_Stmt(StmtBase, WORDClsBase): # R520
"""
subclass_names = []
use_names = ['Object_Name_Deferred_Shape_Spec_List_Item_List']
+ @staticmethod
def match(string):
return WORDClsBase.match('ALLOCATABLE', Object_Name_Deferred_Shape_Spec_List_Item_List, string,
check_colons=True, require_cls=True)
- match = staticmethod(match)
class Asynchronous_Stmt(StmtBase, WORDClsBase): # R521
"""
@@ -2720,6 +2892,7 @@ class Bind_Stmt(StmtBase): # R522
"""
subclass_names = []
use_names = ['Language_Binding_Spec', 'Bind_Entity_List']
+ @staticmethod
def match(string):
i = string.find('::')
if i==-1:
@@ -2732,7 +2905,6 @@ class Bind_Stmt(StmtBase): # R522
rhs = rhs.lstrip()
if not lhs or not rhs: return
return Language_Binding_Spec(lhs), Bind_Entity_List(rhs)
- match = staticmethod(match)
def tostr(self):
return '%s :: %s' % self.items
@@ -2954,7 +3126,7 @@ class Contiguous_Stmt(StmtBase): #R536
subclass_names = []
use_names = [ 'Object_Name_list' ]
def match(string): return WORDClsBase.match('CONTIGUOUS',Pointer_Decl_List,string,check_colons=True, require_cls=True)
- tostr = WORDClsBase.toStr_a
+ tostr = WORDClsBase.tostr_a
match = staticmethod(match)
class Intent_Stmt(StmtBase): # R536
@@ -3345,6 +3517,21 @@ class Common_Block_Object(CallBase): # R558
############################### SECTION 6 ####################################
###############################################################################
+class Fail_Image_Stmt(StmtBase): # R601, F2015
+ """
+ <fail-image-stmt> = FAIL IMAGE
+ """
+ subclass_names = []
+ use_names = []
+ @staticmethod
+ def match(string):
+ try:
+ obj = WORDClsBase.match(pattern.abs_fail_image_name, None, string)
+ except NoMatchError:
+ return obj
+ return
+
+
class Variable(Base): # R601
"""
<variable> = <designator>
@@ -3584,6 +3771,32 @@ class Allocate_Stmt(StmtBase): # R623
return 'ALLOCATE(%s, %s)' % (lst, opts)
else:
return 'ALLOCATE(%s)' % (lst)
+
+class Image_Selector(Base): #R624
+ """
+ <image-selector> = <lbracket-cosubscript-list> [, <team-identifier> ] [, STAT = <stat-variable> ] <rbracket>
+ """
+ subclass_names = []
+ use_names = [ 'Lbracket_Cosubscript_List', 'Team_Identifier', 'Stat_Variable', 'Rbracket' ]
+ # TODO
+
+class Team_Identifier(KeywordValueBase): #R624a
+ """
+ <team-identifier> = TEAM_NUMBER = <scalar-int-expr>
+ | TEAM = <team-variable>
+ """
+ subclass_names = []
+ use_names = [ 'Scalar_Int_Expr' , 'Team_Variable' ]
+ def match(string):
+ for (k,v) in [ ('TEAM_NUMBER', Scalar_Int_Expr), ('TEAM', Team_Variable) ]:
+ try:
+ obj = KeywordValueBase.match(k, v, string, upper_lhs = True)
+ except NoMatchError:
+ obj = None
+ if obj is not None: return obj
+ return
+ match = staticmethod(match)
+
class Alloc_Opt(KeywordValueBase):# R624
"""
@@ -3747,6 +3960,44 @@ class Scalar_Char_Initialization_Expr(Base):
############################### SECTION 7 ####################################
###############################################################################
+class Event_Post_Stmt(StmtBase): # R701, F2015
+ """
+ <event-post-stmt> = EVENT POST ( <event-variable> [ , <sync-stat-list> ] )
+ """
+ subclass_names = []
+ use_names = [ 'Event_Variable', 'Sync_Stat_List' ]
+ # TODO
+
+class Event_Variable(Base): # R702, F2015
+ """
+ <event-variable> = <scalar-variable>
+ """
+ subclass_names = [ 'Scalar_Variable' ]
+
+class Event_Wait_Stmt(StmtBase): # R703, F2015
+ """
+ <event-wait-stmt> = EVENT WAIT (<event-variable> [ , <wait-spec-list> ] )
+ """
+ sublclass_names = []
+ use_names = [ 'Event_Variable', 'Wait_Spec_List' ]
+ # TODO
+
+class Wait_Spec(Base): #R704, F2015
+ """
+ <wait-spec> = <until-spec>
+ | <sync-stat>
+ """
+ subclass_names = [ 'Until_Spec', 'Sync_Stat' ]
+ use_names = []
+
+class Until_Spec(Base): # R705, F2015
+ """
+ <until-spec> = UNTIL COUNT = <scalar-int-expr>
+ """
+ subclass_names = []
+ use_names = [ 'Scalar_Int_Expr' ]
+ # TODO
+
class Primary(Base): # R701
"""
<primary> = <constant>
@@ -4677,6 +4928,15 @@ class Case_Stmt(StmtBase): # R810
return 'CASE %s' % (self.items[0])
return 'CASE %s %s' % (self.items)
+class Critical_Stmt(StmtBase): #R811
+ """
+ <critical-stmt> = [ <critical-construct-name> : ] CRITICAL [ (<sync-stat-list>) ]
+ """
+ # TODO
+ subclass_names = []
+ use_names = [ 'Critical_Construct_Name', 'Sync_Stat_List' ]
+
+
class End_Select_Stmt(EndStmtBase): # R811
"""
<end-select-stmt> = END SELECT [ <case-construct-name> ]
@@ -6581,8 +6841,9 @@ class Module_Subprogram(Base): # R1108
"""
<module-subprogram> = <function-subprogram>
| <subroutine-subprogram>
+ | <separate-module-subprogram>
"""
- subclass_names = ['Function_Subprogram', 'Subroutine_Subprogram']
+ subclass_names = ['Function_Subprogram', 'Subroutine_Subprogram', 'Separate_Module_Subprogram' ]
class Use_Stmt(StmtBase): # R1109
"""
@@ -6698,19 +6959,20 @@ class Use_Defined_Operator(Base): # R1115
"""
subclass_names = ['Defined_Unary_Op', 'Defined_Binary_Op']
-class Block_Data(BlockBase): # R1116
+class Submodule(BlockBase): # R1116
"""
-::
- <block-data> = <block-data-stmt>
- [ <specification-part> ]
- <end-block-data-stmt>
+ <submodule> = <submodule-stmt>
+ [ <specification-part> ]
+ [ <module-subprogram-part> ]
+ <end-module-stmt>
"""
subclass_names = []
- use_names = ['Block_Data_Stmt', 'Specification_Part', 'End_Block_Data_Stmt']
+ use_names = ['Submodule_Stmt', 'Specification_Part', 'Module_Subprogram_Part', 'End_Submodule_Part' ]
@staticmethod
def match(reader):
- return BlockBase.match(Block_Data_Stmt, [Specification_Part], End_Block_Data_Stmt, reader)
+ return BlockBase.match(Submodule_Stmt, [Specification_Part, Mmodule_Subprogram_Part], End_Submodule_Stmt, reader)
+
class Block_Data_Stmt(StmtBase): # R1117
"""
@@ -6744,6 +7006,20 @@ class End_Block_Data_Stmt(EndStmtBase): # R1118
def match(string):
return EndStmtBase.match('BLOCK DATA',Block_Data_Name, string)
+class Block_Data(BlockBase): # WAS:R1116 R1120
+ """
+::
+ <block-data> = <block-data-stmt>
+ [ <specification-part> ]
+ <end-block-data-stmt>
+ """
+ subclass_names = []
+ use_names = ['Block_Data_Stmt', 'Specification_Part', 'End_Block_Data_Stmt']
+
+ @staticmethod
+ def match(reader):
+ return BlockBase.match(Block_Data_Stmt, [Specification_Part], End_Block_Data_Stmt, reader)
+
###############################################################################
############################### SECTION 12 ####################################
@@ -7151,20 +7427,6 @@ class Alt_Return_Spec(Base): # R1222
match = staticmethod(match)
def tostr(self): return '*%s' % (self.items[0])
-class Function_Subprogram(BlockBase): # R1223
- """
- <function-subprogram> = <function-stmt>
- [ <specification-part> ]
- [ <execution-part> ]
- [ <internal-subprogram-part> ]
- <end-function-stmt>
- """
- subclass_names = []
- use_names = ['Function_Stmt', 'Specification_Part', 'Execution_Part',
- 'Internal_Subprogram_Part', 'End_Function_Stmt']
- @staticmethod
- def match(reader):
- return BlockBase.match(Function_Stmt, [Specification_Part, Execution_Part, Internal_Subprogram_Part], End_Function_Stmt, reader)
class Function_Stmt(StmtBase): # R1224
"""
@@ -7249,6 +7511,21 @@ class Prefix_Spec(STRINGBase): # R1228
return STRINGBase.match(['RECURSIVE', 'PURE', 'ELEMENTAL'], string)
match = staticmethod(match)
+class Function_Subprogram(BlockBase): # WAS:R1223 R1229
+ """
+ <function-subprogram> = <function-stmt>
+ [ <specification-part> ]
+ [ <execution-part> ]
+ [ <internal-subprogram-part> ]
+ <end-function-stmt>
+ """
+ subclass_names = []
+ use_names = ['Function_Stmt', 'Specification_Part', 'Execution_Part',
+ 'Internal_Subprogram_Part', 'End_Function_Stmt']
+ @staticmethod
+ def match(reader):
+ return BlockBase.match(Function_Stmt, [Specification_Part, Execution_Part, Internal_Subprogram_Part], End_Function_Stmt, reader)
+
class Suffix(Base): # R1229
"""
<suffix> = <proc-language-binding-spec> [ RESULT ( <result-name> ) ]
@@ -7293,21 +7570,6 @@ class End_Function_Stmt(EndStmtBase): # R1230
def match(string): return EndStmtBase.match('FUNCTION',Function_Name, string)
match = staticmethod(match)
-class Subroutine_Subprogram(BlockBase): # R1231
- """
- <subroutine-subprogram> = <subroutine-stmt>
- [ <specification-part> ]
- [ <execution-part> ]
- [ <internal-subprogram-part> ]
- <end-subroutine-stmt>
- """
- subclass_names = []
- use_names = ['Subroutine_Stmt', 'Specification_Part', 'Execution_Part',
- 'Internal_Subprogram_Part', 'End_Subroutine_Stmt']
- def match(reader):
- return BlockBase.match(Subroutine_Stmt, [Specification_Part, Execution_Part, Internal_Subprogram_Part], End_Subroutine_Stmt, reader)
- match = staticmethod(match)
-
class Subroutine_Stmt(StmtBase): # R1232
"""
<subroutine-stmt> = [ <prefix> ] SUBROUTINE <subroutine-name> [ ( [ <dummy-arg-list> ] ) [ <proc-language-binding-spec> ] ]
@@ -7369,6 +7631,21 @@ class End_Subroutine_Stmt(EndStmtBase): # R1234
@staticmethod
def match(string): return EndStmtBase.match('SUBROUTINE', Subroutine_Name, string)
+class Subroutine_Subprogram(BlockBase): # WAS:R1231 R1235
+ """
+ <subroutine-subprogram> = <subroutine-stmt>
+ [ <specification-part> ]
+ [ <execution-part> ]
+ [ <internal-subprogram-part> ]
+ <end-subroutine-stmt>
+ """
+ subclass_names = []
+ use_names = ['Subroutine_Stmt', 'Specification_Part', 'Execution_Part',
+ 'Internal_Subprogram_Part', 'End_Subroutine_Stmt']
+ def match(reader):
+ return BlockBase.match(Subroutine_Stmt, [Specification_Part, Execution_Part, Internal_Subprogram_Part], End_Subroutine_Stmt, reader)
+ match = staticmethod(match)
+
class Entry_Stmt(StmtBase): # R1235
"""
::
@@ -7461,6 +7738,23 @@ class Stmt_Function_Stmt(StmtBase): # R1238
return '%s () = %s' % (self.items[0], self.items[2])
return '%s (%s) = %s' % self.items
+class Separate_Module_Subprogram(Base): #R1239
+ """
+:F08R:`1239`::
+ <separate-module-subprogram> = <mp-subprogram-stmt>
+ [ <specification-part> ]
+ [ <execution-part> ]
+ [ <internal-subprogram-part> ]
+ <end-mp-subprogram-stmt>
+ """
+ subclass_names = []
+ use_names = [ 'MP_Subprogram_Stmt', 'Specification_Part', 'Execution_Part', 'Internal_Subprogram_Part',
+ 'End_MP_Subprogram_Stmt' ]
+
+ def match(reader):
+ return BlockBase.match(MP_Subprogram_Stmt, [Specification_Part, Execution_Part, Internal_Subprogram_Part], End_MP_Subroutine_Stmt, reader)
+ match = staticmethod(match)
+
###############################################################################
################ GENERATE Scalar_, _List, _Name CLASSES #######################
###############################################################################
diff --git a/src/fparser/tests/test_Fortran2015.py b/src/fparser/tests/test_Fortran2015.py
index 1deb735..24c1c7d 100644
--- a/src/fparser/tests/test_Fortran2015.py
+++ b/src/fparser/tests/test_Fortran2015.py
@@ -1470,6 +1470,17 @@ def test_Common_Block_Object(): # R558
############################### SECTION 6 ####################################
###############################################################################
+def test_Fail_Image(): # R601, F2015
+ cls = Fail_Image_Stmt
+ a = cls('FAIL IMAGE')
+ assert isinstance(a, cls), repr(a)
+ assert_equal(str(a), 'FAIL IMAGE')
+ assert_equal(repr(a), 'FailImage()')
+ a = cls('FAIL IMAGE')
+ assert isinstance(a, cls), repr(a)
+ assert_equal(str(a), 'FAIL IMAGE')
+ assert_equal(repr(a), 'FailImage()')
+
def test_Substring(): # R609
cls = Substring
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/fparser.git
More information about the Python-modules-commits
mailing list