@@ -574,11 +574,16 @@ def readfortrancode(ffile, dowithline=show, istop=1):
574
574
groupends = (r'end|endprogram|endblockdata|endmodule|endpythonmodule|'
575
575
r'endinterface|endsubroutine|endfunction' )
576
576
endpattern = re .compile (
577
- beforethisafter % ('' , groupends , groupends , r'[\w\s]*' ), re .I ), 'end'
578
- endifs = r'(end\s*(if|do|where|select|while|forall|associate|block|critical|enum|team))|(module\s*procedure)'
577
+ beforethisafter % ('' , groupends , groupends , r'.*' ), re .I ), 'end'
578
+ endifs = r'end\s*(if|do|where|select|while|forall|associate|block|' + \
579
+ r'critical|enum|team)'
579
580
endifpattern = re .compile (
580
581
beforethisafter % (r'[\w]*?' , endifs , endifs , r'[\w\s]*' ), re .I ), 'endif'
581
582
#
583
+ moduleprocedures = r'module\s*procedure'
584
+ moduleprocedurepattern = re .compile (
585
+ beforethisafter % ('' , moduleprocedures , moduleprocedures , r'.*' ), re .I ), \
586
+ 'moduleprocedure'
582
587
implicitpattern = re .compile (
583
588
beforethisafter % ('' , 'implicit' , 'implicit' , '.*' ), re .I ), 'implicit'
584
589
dimensionpattern = re .compile (beforethisafter % (
@@ -727,7 +732,8 @@ def crackline(line, reset=0):
727
732
callpattern , usepattern , containspattern ,
728
733
entrypattern ,
729
734
f2pyenhancementspattern ,
730
- multilinepattern
735
+ multilinepattern ,
736
+ moduleprocedurepattern
731
737
]:
732
738
m = pat [0 ].match (line )
733
739
if m :
@@ -797,6 +803,8 @@ def crackline(line, reset=0):
797
803
expectbegin = 0
798
804
elif pat [1 ] == 'endif' :
799
805
pass
806
+ elif pat [1 ] == 'moduleprocedure' :
807
+ analyzeline (m , pat [1 ], line )
800
808
elif pat [1 ] == 'contains' :
801
809
if ignorecontains :
802
810
return
@@ -886,6 +894,9 @@ def appenddecl(decl, decl2, force=1):
886
894
r'\s*(?P<this>(@\(@.*?@\)@|\*[\d*]+|\*\s*@\(@.*?@\)@|))(?P<after>.*)\Z' , re .I )
887
895
nameargspattern = re .compile (
888
896
r'\s*(?P<name>\b[\w$]+\b)\s*(@\(@\s*(?P<args>[\w\s,]*)\s*@\)@|)\s*((result(\s*@\(@\s*(?P<result>\b[\w$]+\b)\s*@\)@|))|(bind\s*@\(@\s*(?P<bind>.*)\s*@\)@))*\s*\Z' , re .I )
897
+ operatorpattern = re .compile (
898
+ r'\s*(?P<scheme>(operator|assignment))'
899
+ r'@\(@\s*(?P<name>[^)]+)\s*@\)@\s*\Z' , re .I )
889
900
callnameargspattern = re .compile (
890
901
r'\s*(?P<name>\b[\w$]+\b)\s*@\(@\s*(?P<args>.*)\s*@\)@\s*\Z' , re .I )
891
902
real16pattern = re .compile (
@@ -908,6 +919,10 @@ def _resolvenameargspattern(line):
908
919
m1 = nameargspattern .match (line )
909
920
if m1 :
910
921
return m1 .group ('name' ), m1 .group ('args' ), m1 .group ('result' ), m1 .group ('bind' )
922
+ m1 = operatorpattern .match (line )
923
+ if m1 :
924
+ name = m1 .group ('scheme' ) + '(' + m1 .group ('name' ) + ')'
925
+ return name , [], None , None
911
926
m1 = callnameargspattern .match (line )
912
927
if m1 :
913
928
return m1 .group ('name' ), m1 .group ('args' ), None , None
@@ -1151,6 +1166,9 @@ def analyzeline(m, case, line):
1151
1166
continue
1152
1167
else :
1153
1168
k = rmbadname1 (m1 .group ('name' ))
1169
+ if case in ['public' , 'private' ] and \
1170
+ (k == 'operator' or k == 'assignment' ):
1171
+ k += m1 .group ('after' )
1154
1172
if k not in edecl :
1155
1173
edecl [k ] = {}
1156
1174
if case == 'dimension' :
@@ -1193,6 +1211,9 @@ def analyzeline(m, case, line):
1193
1211
groupcache [groupcounter ]['vars' ] = edecl
1194
1212
if last_name is not None :
1195
1213
previous_context = ('variable' , last_name , groupcounter )
1214
+ elif case == 'moduleprocedure' :
1215
+ groupcache [groupcounter ]['implementedby' ] = \
1216
+ [x .strip () for x in m .group ('after' ).split (',' )]
1196
1217
elif case == 'parameter' :
1197
1218
edecl = groupcache [groupcounter ]['vars' ]
1198
1219
ll = m .group ('after' ).strip ()[1 :- 1 ]
@@ -2105,7 +2126,8 @@ def analyzebody(block, args, tab=''):
2105
2126
else :
2106
2127
as_ = args
2107
2128
b = postcrack (b , as_ , tab = tab + '\t ' )
2108
- if b ['block' ] in ['interface' , 'abstract interface' ] and not b ['body' ]:
2129
+ if b ['block' ] in ['interface' , 'abstract interface' ] and \
2130
+ not b ['body' ] and not b ['implementedby' ]:
2109
2131
if 'f2pyenhancements' not in b :
2110
2132
continue
2111
2133
if b ['block' ].replace (' ' , '' ) == 'pythonmodule' :
0 commit comments