67 Fortran single line statements. 86 extract_bracketed_list_items,
175 <statement> [ :: ] <name-list> 178 def process_item(self):
179 if self.
item.has_map():
182 if hasattr(self,
"stmtname"):
183 clsname = self.stmtname
185 clsname = self.__class__.__name__
186 line = self.
item.get_line()[len(clsname) :].lstrip()
187 if line.startswith(
"::"):
188 line = line[2:].lstrip()
189 self.
items = items = []
190 for item
in split_comma(line):
191 if not is_name(item):
197 def tofortran(self, isfix=None):
198 if hasattr(self,
"stmtname"):
199 clsname = self.stmtname.upper()
201 clsname = self.__class__.__name__.upper()
202 s =
", ".join(self.
items)
214 <pointer variable> => <expr> 217 match = re.compile(
r"\w[^=]*\s*=>?").match
218 item_re = re.compile(
219 r"(?P<variable>\w[^=]*)\s*(?P<sign>=>?)\s*(?P<expr>.*)\Z", re.I
221 _repr_attr_names = [
"variable",
"sign",
"expr"] + Statement._repr_attr_names
223 def process_item(self):
228 self.
sign = sign = m.group(
"sign")
229 if isinstance(self, Assignment)
and sign !=
"=":
232 elif isinstance(self, PointerAssignment)
and sign !=
"=>":
240 apply_map = self.
item.apply_map
241 v1 = v = m.group(
"variable").replace(
" ",
"")
247 if v.startswith(
"(")
or v.startswith(
r"%"):
253 self.
expr = apply_map(m.group(
"expr"))
256 def tofortran(self, isfix=None):
267 class Assignment(GeneralAssignment):
277 ASSIGN <label> TO <int-variable-name> 281 match = re.compile(
r"assign\s*\d+\s*to\s*\w+\s*\Z", re.I).match
283 def process_item(self):
284 line = self.item.get_line()[6:].lstrip()
285 i = line.lower().find(
"to")
286 assert not self.item.has_map()
287 self.items = [line[:i].rstrip(), line[i + 2 :].lstrip()]
290 def tofortran(self, isfix=None):
291 return self.get_indent_tab(isfix=isfix) +
"ASSIGN %s TO %s" % (
300 class Call(Statement):
301 """Call statement class 302 CALL <procedure-designator> [ ( [ <actual-arg-spec-list> ] ) ] 304 <procedure-designator> = <procedure-name> 305 | <proc-component-ref> 306 | <data-ref> % <binding-name> 308 <actual-arg-spec> = [ <keyword> = ] <actual-arg> 309 <actual-arg> = <expr> 312 | <proc-component-ref> 314 <alt-return-spec> = * <label> 316 <proc-component-ref> = <variable> % <procedure-component-name> 318 <variable> = <designator> 320 Call instance has attributes: 330 match = re.compile(
r"call\b\s*\w([\s\w\(\)\%]*\w)?\s*(\(.*\))?\s*$", re.I).match
333 """Parse the string containing the Call and store the 334 designator and list of arguments (if any)""" 336 apply_map = item.apply_map
337 line = item.get_line()[4:].strip()
346 if line.endswith(
")"):
365 items = split_comma(line[i + 1 : -1], item)
374 """Returns the Fortran representation of this object as a string""" 377 txt +=
"(" +
", ".join(map(str, self.
items)) +
")" 382 variables = a.variables
383 if hasattr(a,
"external"):
384 external = a.external
386 print(
"Need to analyze:", self, file=sys.stderr)
395 match = re.compile(
r"go\s*to\s*\d+\s*\Z", re.I).match
397 def process_item(self):
398 assert not self.
item.has_map()
399 self.
label = self.
item.get_line()[2:].lstrip()[2:].lstrip()
402 def tofortran(self, isfix=None):
409 class ComputedGoto(Statement):
411 GO TO ( <label-list> ) [ , ] <scalar-int-expr> 414 match = re.compile(
r"go\s*to\s*\(", re.I).match
416 def process_item(self):
417 apply_map = self.item.apply_map
418 line = self.item.get_line()[2:].lstrip()[2:].lstrip()
420 self.items = split_comma(line[1:i], self.item)
421 line = line[i + 1 :].lstrip()
422 if line.startswith(
","):
423 line = line[1:].lstrip()
424 self.expr = apply_map(line)
427 def tofortran(self, isfix=None):
428 return self.get_indent_tab(isfix=isfix) +
"GO TO (%s) %s" % (
429 ", ".join(self.items),
437 class AssignedGoto(Statement):
439 GO TO <int-variable-name> [ ( <label> [ , <label> ]... ) ] 443 match = re.compile(
r"go\s*to\s*\w+\s*\(?", re.I).match
445 def process_item(self):
446 line = self.item.get_line()[2:].lstrip()[2:].lstrip()
452 self.varname = line[:i].rstrip()
453 assert line[-1] ==
")", repr(line)
455 self.items = split_comma(line[i + 1 : -1], self.item)
458 def tofortran(self, isfix=None):
459 tab = self.get_indent_tab(isfix=isfix)
461 return tab +
"GO TO %s (%s)" % (self.varname,
", ".join(self.items))
462 return tab +
"GO TO %s" % (self.varname)
468 class Continue(Statement):
473 match = re.compile(
r"continue\Z", re.I).match
475 def process_item(self):
476 self.label = self.item.label
479 def tofortran(self, isfix=None):
480 return self.get_indent_tab(deindent=
True) +
"CONTINUE" 486 class Return(Statement):
488 RETURN [ <scalar-int-expr> ] 491 match = re.compile(
r"return\b", re.I).match
493 def process_item(self):
494 self.expr = self.item.apply_map(self.item.get_line()[6:].lstrip())
497 def tofortran(self, isfix=None):
498 tab = self.get_indent_tab(isfix=isfix)
500 return tab +
"RETURN %s" % (self.expr)
501 return tab +
"RETURN" 507 class Stop(Statement):
510 <stop-code> = <scalar-char-constant> | <1-5-digit> 513 match = re.compile(
r'stop\s*((\'\w*\'|"\w*")+|\d+|)\Z', re.I).match
515 def process_item(self):
516 self.code = self.item.apply_map(self.item.get_line()[4:].lstrip())
519 def tofortran(self, isfix=None):
520 tab = self.get_indent_tab(isfix=isfix)
522 return tab +
"STOP %s" % (self.code)
529 class Print(Statement):
531 PRINT <format> [, <output-item-list>] 532 <format> = <default-char-expr> | <label> | * 534 <output-item> = <expr> | <io-implied-do> 535 <io-implied-do> = ( <io-implied-do-object-list> , <implied-do-control> ) 536 <io-implied-do-object> = <input-item> | <output-item> 537 <implied-do-control> = <do-variable> 538 = <scalar-int-expr> , 539 <scalar-int-expr> [ , <scalar-int-expr> ] 540 <input-item> = <variable> | <io-implied-do> 543 match = re.compile(
r"print\s*(\'\w*\'|\"\w*\"|\d+|[*]|\b\w)", re.I).match
545 def process_item(self):
547 apply_map = item.apply_map
548 line = item.get_line()[5:].lstrip()
549 items = split_comma(line, item)
550 self.format = items[0]
551 self.items = items[1:]
554 def tofortran(self, isfix=None):
555 return self.get_indent_tab(isfix=isfix) +
"PRINT %s" % (
556 ", ".join([self.format] + self.items)
563 class Read(Statement):
565 Read0: READ ( <io-control-spec-list> ) [ <input-item-list> ] 567 <io-control-spec-list> = [ UNIT = ] <io-unit> 568 | [ FORMAT = ] <format> 569 | [ NML = ] <namelist-group-name> 570 | ADVANCE = <scalar-default-char-expr> 573 Read1: READ <format> [, <input-item-list>] 574 <format> == <default-char-expr> | <label> | * 577 match = re.compile(
r'read\b\s*[\w(*\'"]', re.I).match
579 def process_item(self):
581 line = item.get_line()[4:].lstrip()
582 if line.startswith(
"("):
583 self.__class__ = Read0
585 self.__class__ = Read1
594 def process_item(self):
596 line = item.get_line()[4:].lstrip()
598 self.specs = specs_split_comma(line[1:i], item)
599 self.items = split_comma(line[i + 1 :], item)
602 def tofortran(self, isfix=None):
603 s = self.get_indent_tab(isfix=isfix) +
"READ (%s)" % (
", ".join(self.specs))
605 return s +
" " +
", ".join(self.items)
610 def process_item(self):
612 line = item.get_line()[4:].lstrip()
613 items = split_comma(line, item)
615 self.
items = items[1:]
618 def tofortran(self, isfix=None):
628 WRITE ( io-control-spec-list ) [<output-item-list>] 631 match = re.compile(
r"write\s*\(", re.I).match
633 def process_item(self):
635 line = item.get_line()[5:].lstrip()
637 assert i != -1, repr(line)
638 self.
specs = specs_split_comma(line[1:i], item)
639 self.
items = split_comma(line[i + 1 :], item)
642 def tofortran(self, isfix=None):
645 s +=
" " +
", ".join(self.
items)
652 class Flush(Statement):
654 FLUSH <file-unit-number> 655 FLUSH ( <flush-spec-list> ) 656 <flush-spec> = [ UNIT = ] <file-unit-number> 657 | IOSTAT = <scalar-int-variable> 658 | IOMSG = <iomsg-variable> 662 match = re.compile(
r"flush\b", re.I).match
664 def process_item(self):
665 line = self.item.get_line()[5:].lstrip()
669 if line.startswith(
"("):
670 assert line[-1] ==
")", repr(line)
671 self.specs = specs_split_comma(line[1:-1], self.item)
673 self.specs = specs_split_comma(line, self.item)
676 def tofortran(self, isfix=None):
677 tab = self.get_indent_tab(isfix=isfix)
678 return tab +
"FLUSH (%s)" % (
", ".join(self.specs))
684 class Wait(Statement):
686 WAIT ( <wait-spec-list> ) 687 <wait-spec> = [ UNIT = ] <file-unit-number> 691 | ID = <scalar-int-expr> 692 | IOMSG = <iomsg-variable> 693 | IOSTAT = <scalar-int-variable> 697 match = re.compile(
r"wait\s*\(.*\)\Z", re.I).match
699 def process_item(self):
700 self.specs = specs_split_comma(
701 self.item.get_line()[4:].lstrip()[1:-1], self.item
705 def tofortran(self, isfix=None):
706 tab = self.get_indent_tab(isfix=isfix)
707 return tab +
"WAIT (%s)" % (
", ".join(self.specs))
713 class Contains(Statement):
718 match = re.compile(
r"contains\Z", re.I).match
720 def process_item(self):
723 def tofortran(self, isfix=None):
724 return self.get_indent_tab(isfix=isfix) +
"CONTAINS" 729 ALLOCATE ( [ <type-spec> :: ] <allocation-list> [ , <alloc-opt-list> ] ) 730 <alloc-opt> = STAT = <stat-variable> 731 | ERRMSG = <errmsg-variable> 732 | SOURCE = <source-expr> 733 <allocation> = <allocate-object> [ ( <allocate-shape-spec-list> ) ] 736 match = re.compile(
r"allocate\s*\(.*\)\Z", re.I).match
740 Process the ALLOCATE statement and store the various entities being 741 allocated in self.items. Any type-specification is stored in 744 :raises ParseError: if an invalid type-specification is used 746 line = self.
item.get_line()[8:].lstrip()[1:-1].strip()
747 item2 = self.
item.copy(line,
True)
748 line2 = item2.get_line()
751 spec = item2.apply_map(line2[:i].rstrip())
752 from .block_statements
import type_spec
755 for cls
in type_spec:
757 stmt = cls(self, item2.copy(spec))
760 if stmt
is not None and stmt.isvalid:
767 "Unrecognised type-specification in ALLOCATE statement: " 768 "{0}".format(self.
item.line)
770 line2 = line2[i + 2 :].lstrip()
774 self.
items = specs_split_comma(line2, item2)
779 Create the Fortran code for this ALLOCATE statement 781 :param bool isfix: whether or not to generate fixed-format code 782 :return: Fortran code 787 if isinstance(self.
spec, str):
788 type_spec = self.
spec 790 type_spec = self.
spec.tostr()
794 ", ".join(self.
items),
801 class Deallocate(Statement):
803 DEALLOCATE ( <allocate-object-list> [ , <dealloc-opt-list> ] ) 804 <allocate-object> = <variable-name> 805 | <structure-component> 806 <structure-component> = <data-ref> 807 <dealloc-opt> = STAT = <stat-variable> 808 | ERRMSG = <errmsg-variable> 811 match = re.compile(
r"deallocate\s*\(.*\)\Z", re.I).match
813 def process_item(self):
814 line = self.item.get_line()[10:].lstrip()[1:-1].strip()
815 self.items = specs_split_comma(line, self.item)
818 def tofortran(self, isfix=None):
819 return self.get_indent_tab(isfix=isfix) +
"DEALLOCATE (%s)" % (
820 ", ".join(self.items)
827 class ModuleProcedure(Statement):
829 [ MODULE ] PROCEDURE [::] <procedure-name-list> 832 match = re.compile(
r"(module\s*|)procedure\b\s*(::)?", re.I).match
834 def process_item(self):
835 line = self.item.get_line()
838 items = split_comma(line[m.end() :].strip(), self.item)
846 def tofortran(self, isfix=None):
847 tab = self.get_indent_tab(isfix=isfix)
848 return tab +
"MODULE PROCEDURE %s" % (
", ".join(self.items))
851 module_procedures = self.parent.a.module_procedures
852 module_procedures.extend(self.items)
859 <access-spec> [ [::] <access-id-list>] 860 <access-spec> = PUBLIC | PRIVATE 861 <access-id> = <use-name> | <generic-spec> 864 match = re.compile(
r"(public|private)\b", re.I).match
866 def process_item(self):
867 clsname = self.__class__.__name__.lower()
868 line = self.
item.get_line()
869 if not line.lower().startswith(clsname):
872 line = line[len(clsname) :].lstrip()
873 if line.startswith(
"::"):
874 line = line[2:].lstrip()
875 self.
items = split_comma(line, self.
item)
878 def tofortran(self, isfix=None):
879 clsname = self.__class__.__name__.upper()
882 return tab + clsname +
" " +
", ".join(self.
items)
886 clsname = self.__class__.__name__
887 bits = getattr(self.
parent.a, clsname.lower() +
"_id_list")
889 for name
in self.
items:
895 if not isinstance(self.
parent, classes.Module):
896 parentclsname = self.
parent.__class__.__name__
898 "C548 violation: %s statement only allowed in the" 899 " specification-part of a module, not in a %s." 900 % (clsname.upper(), parentclsname.lower())
903 access_id_list = self.
parent.a.private_id_list + self.
parent.a.public_id_list
904 if access_id_list.count(
"") > 1:
906 "C548 violation: only one access-stmt with omitted" 907 " access-id-list is permitted in" 908 " the module-specification-part." 927 CLOSE ( <close-spec-list> ) 928 <close-spec> = [ UNIT = ] <file-unit-number> 929 | IOSTAT = <scalar-int-variable> 930 | IOMSG = <iomsg-variable> 932 | STATUS = <scalar-default-char-expr> 935 match = re.compile(
r"close\s*\(.*\)\Z", re.I).match
937 def process_item(self):
938 line = self.
item.get_line()[5:].lstrip()[1:-1].strip()
939 self.
specs = specs_split_comma(line, self.
item)
942 def tofortran(self, isfix=None):
944 return tab +
"CLOSE (%s)" % (
", ".join(self.
specs))
950 class Cycle(Statement):
952 CYCLE [ <do-construct-name> ] 955 match = re.compile(
r"cycle\b\s*\w*\s*\Z", re.I).match
957 def process_item(self):
958 self.name = self.item.get_line()[5:].lstrip()
961 def tofortran(self, isfix=None):
963 return self.get_indent_tab(isfix=isfix) +
"CYCLE " + self.name
964 return self.get_indent_tab(isfix=isfix) +
"CYCLE" 970 class FilePositioningStatement(Statement):
972 REWIND <file-unit-number> 973 REWIND ( <position-spec-list> ) 974 <position-spec-list> = [ UNIT = ] <file-unit-number> 975 | IOMSG = <iomsg-variable> 976 | IOSTAT = <scalar-int-variable> 978 The same for BACKSPACE, ENDFILE. 981 match = re.compile(
r"(rewind|backspace|endfile)\b", re.I).match
983 def process_item(self):
984 clsname = self.__class__.__name__.lower()
985 line = self.item.get_line()
986 if not line.lower().startswith(clsname):
989 line = line[len(clsname) :].lstrip()
990 if line.startswith(
"("):
991 assert line[-1] ==
")", repr(line)
992 spec = line[1:-1].strip()
995 self.specs = specs_split_comma(spec, self.item)
998 def tofortran(self, isfix=None):
999 clsname = self.__class__.__name__.upper()
1001 self.get_indent_tab(isfix=isfix)
1003 +
" (%s)" % (
", ".join(self.specs))
1010 class Backspace(FilePositioningStatement):
1024 OPEN ( <connect-spec-list> ) 1025 <connect-spec> = [ UNIT = ] <file-unit-number> 1026 | ACCESS = <scalar-default-char-expr> 1030 match = re.compile(
r"open\s*\(.*\)\Z", re.I).match
1032 def process_item(self):
1033 line = self.item.get_line()[4:].lstrip()[1:-1].strip()
1034 self.specs = specs_split_comma(line, self.item)
1037 def tofortran(self, isfix=None):
1038 return self.get_indent_tab(isfix=isfix) +
"OPEN (%s)" % (
", ".join(self.specs))
1044 class Format(Statement):
1046 FORMAT <format-specification> 1047 <format-specification> = ( [ <format-item-list> ] ) 1048 <format-item> = [ <r> ] <data-edit-descr> 1049 | <control-edit-descr> 1050 | <char-string-edit-descr> 1051 | [ <r> ] ( <format-item-list> ) 1052 <data-edit-descr> = I <w> [ . <m> ] 1055 <r|w|m|d|e> = <int-literal-constant> 1056 <v> = <signed-int-literal-constant> 1057 <control-edit-descr> = <position-edit-descr> 1061 <position-edit-descr> = T <n> 1064 <sign-edit-descr> = SS | SP | S 1069 match = re.compile(
r"format\s*\(.*\)\Z", re.I).match
1071 def process_item(self):
1073 if item.label
is None:
1076 "FORMAT statement must be labeled (F2008:C1001)." % (item.label)
1078 line = item.get_line()[6:].lstrip()
1079 assert line[0] + line[-1] ==
"()", repr(line)
1080 self.specs = split_comma(line[1:-1], item)
1083 def tofortran(self, isfix=None):
1084 return self.get_indent_tab(isfix=isfix) +
"FORMAT (%s)" % (
1085 ", ".join(self.specs)
1092 class Save(Statement):
1094 SAVE [ [ :: ] <saved-entity-list> ] 1095 <saved-entity> = <object-name> 1096 | <proc-pointer-name> 1097 | / <common-block-name> / 1098 <proc-pointer-name> = <name> 1099 <object-name> = <name> 1102 match = re.compile(
r"save\b", re.I).match
1104 def process_item(self):
1105 assert not self.item.has_map()
1106 line = self.item.get_line()[4:].lstrip()
1107 if line.startswith(
"::"):
1108 line = line[2:].lstrip()
1110 for s
in line.split(
","):
1114 if s.startswith(
"/"):
1115 assert s.endswith(
"/"), repr(s)
1117 assert is_name(n), repr(n)
1118 items.append(
"/%s/" % (n))
1122 self.isvalid =
False 1127 def tofortran(self, isfix=None):
1128 tab = self.get_indent_tab(isfix=isfix)
1131 return tab +
"SAVE %s" % (
", ".join(self.items))
1137 class Data(Statement):
1139 DATA <data-stmt-set> [ [ , ] <data-stmt-set> ]... 1140 <data-stmt-set> = <data-stmt-object-list> / <data-stmt-value-list> / 1141 <data-stmt-object> = <variable> | <data-implied-do> 1142 <data-implied-do> = ( <data-i-do-object-list> , 1143 <data-i-do-variable> = <scalar-int-expr> , 1144 <scalar-int-expr> [ , <scalar-int-expr> ] ) 1145 <data-i-do-object> = <array-element> 1146 | <scalar-structure-component> 1148 <data-i-do-variable> = <scalar-int-variable> 1149 <variable> = <designator> 1150 <designator> = <object-name> 1153 | <structure-component> 1155 <array-element> = <data-ref> 1156 <array-section> = <data-ref> [ ( <substring-range> ) ] 1160 match = re.compile(
r"data\b", re.I).match
1162 def process_item(self):
1163 line = self.item.get_line()[4:].lstrip()
1165 self.isvalid =
False 1170 j = line.find(
"/", i + 1)
1173 l1, l2 = line[:i].rstrip(), line[i + 1 : j].strip()
1174 l1 = split_comma(l1, self.item)
1175 l2 = split_comma(l2, self.item)
1176 stmts.append((l1, l2))
1177 line = line[j + 1 :].lstrip()
1178 if line.startswith(
","):
1179 line = line[1:].lstrip()
1184 def tofortran(self, isfix=None):
1185 tab = self.get_indent_tab(isfix=isfix)
1187 for o, v
in self.stmts:
1188 bits.append(
"%s / %s /" % (
", ".join(o),
", ".join(v)))
1189 return tab +
"DATA " +
" ".join(bits)
1195 class Nullify(Statement):
1197 NULLIFY ( <pointer-object-list> ) 1198 <pointer-object> = <variable-name> 1201 match = re.compile(
r"nullify\s*\(.*\)\Z", re.I).match
1203 def process_item(self):
1204 line = self.item.get_line()[7:].lstrip()[1:-1].strip()
1205 self.items = split_comma(line, self.item)
1208 def tofortran(self, isfix=None):
1209 return self.get_indent_tab(isfix=isfix) +
"NULLIFY (%s)" % (
1210 ", ".join(self.items)
1217 class Use(Statement):
1218 """Parses USE statement. 1220 :param class Statement: Base fparser class. 1221 :raises AnalyzeError: If entity name is not in module. 1223 Fortran syntax construct: 1225 USE [ [ , <module-nature> ] :: ] <module-name> [ , <rename-list> ] 1226 USE [ [ , <module-nature> ] :: ] <module-name> , ONLY : [ <only-list> ] 1227 <module-nature> = INTRINSIC | NON_INTRINSIC 1228 <rename> = <local-name> => <use-name> 1229 | OPERATOR ( <local-defined-operator> ) => 1230 OPERATOR ( <use-defined-operator> ) 1231 <only> = <generic-spec> | <only-use-name> | <rename> 1232 <only-use-name> = <use-name> 1235 match = re.compile(
r"use\b", re.I).match
1238 """Parse the string containing the Use and store the 1239 module name and list of attributes (if any)""" 1240 line = self.
item.get_line()[3:].lstrip()
1242 if line.startswith(
","):
1244 nature = line[1:i].strip().upper()
1245 line = line[i + 2 :].lstrip()
1246 if line.startswith(
"::"):
1247 line = line[2:].lstrip()
1248 if nature
and not is_name(nature):
1258 self.
name = line[:i].rstrip()
1259 line = line[i + 1 :].lstrip()
1260 if line.lower().startswith(
"only")
and line[4:].lstrip().startswith(
":"):
1262 line = line[4:].lstrip()[1:].lstrip()
1263 self.
items = split_comma(line, self.
item)
1268 Returns the Fortran representation of this object as a string 1270 :param bool isfix: Whether or not to generated fixed-format Fortran 1271 :return: Fortran representation of this object 1277 s +=
", " + self.
nature +
" ::" 1278 s +=
" " + self.
name 1284 s +=
" " +
", ".join(self.
items)
1288 """Returns warnings if this object is incorrect""" 1290 if self.
name in use:
1293 modules = self.
top.a.module
1294 if self.
name not in modules:
1295 fn = self.
reader.find_module_source_file(self.
name)
1300 self.
info(
"looking module information from %r" % (fn))
1301 reader = FortranFileReader(
1303 include_dirs=self.
reader.include_dirs,
1304 source_only=self.
reader.source_only,
1306 parser = FortranParser(reader)
1308 parser.block.a.module.update(modules)
1310 modules.update(parser.block.a.module)
1312 if self.
name not in modules:
1314 "no information about the module %r in use statement" % (self.
name)
1318 module = modules[self.
name]
1319 use[self.
name] = module
1320 use_provides = self.
parent.a.use_provides
1321 renames = [split_comma(item, comma=
"=>")
for item
in self.
items if "=>" in item]
1322 norenames = [item
for item
in self.
items if "=>" not in item]
1323 all_mod_provides = dict(module.a.module_provides)
1324 all_mod_provides.update(module.a.use_provides)
1327 for rename, orig
in renames:
1329 for name
in norenames:
1335 "'use' without 'only' clause does not rename the " 1336 "variables '%s'" %
", ".join(norenames)
1339 for rename, orig
in renames:
1342 unrenamed = set(all_mod_provides) - set([b
for (a, b)
in renames])
1343 for name
in unrenamed:
1348 """Checks for entity name in the module""" 1349 ovar = all_mod_provides.get(name,
None)
1352 "entity name '%s' is not in module '%s'" % (name, self.
name)
1359 if name_idx
in use_provides:
1360 if ovar != use_provides[name_idx]:
1362 "entity name '%s' is already declared in module " 1363 "'%s' while adding it to '%s', overriding." 1366 use_provides[name_idx] = ovar
1371 EXIT [ <do-construct-name> ] 1374 match = re.compile(
r"exit\b\s*\w*\s*\Z", re.I).match
1376 def process_item(self):
1377 self.
name = self.
item.get_line()[4:].lstrip()
1380 def tofortran(self, isfix=None):
1389 class Parameter(Statement):
1391 PARAMETER ( <named-constant-def-list> ) 1392 <named-constant-def> = <named-constant> = <initialization-expr> 1395 match = re.compile(
r"parameter\s*\(.*\)\Z", re.I).match
1397 def process_item(self):
1398 line = self.item.get_line()[9:].lstrip()[1:-1].strip()
1399 self.items = split_comma(line, self.item)
1402 def tofortran(self, isfix=None):
1403 return self.get_indent_tab(isfix=isfix) +
"PARAMETER (%s)" % (
1404 ", ".join(self.items)
1408 for item
in self.items:
1410 assert i != -1, repr(item)
1411 name = item[:i].rstrip()
1412 value = item[i + 1 :].lstrip()
1413 var = self.get_variable(name)
1414 var.update(
"parameter")
1421 EQUIVALENCE <equivalence-set-list> 1422 <equivalence-set> = ( <equivalence-object> , <equivalence-object-list> ) 1423 <equivalence-object> = <variable-name> | <array-element> | <substring> 1426 match = re.compile(
r"equivalence\s*\(.*\)\Z", re.I).match
1428 def process_item(self):
1430 for s
in self.
item.get_line()[11:].lstrip().split(
","):
1432 assert s[0] + s[-1] ==
"()", repr((s, self.
item.get_line()))
1433 s =
", ".join(split_comma(s[1:-1], self.
item))
1434 items.append(
"(" + s +
")")
1438 def tofortran(self, isfix=None):
1440 ", ".join(self.
items)
1447 class Dimension(Statement):
1449 DIMENSION [ :: ] <array-name> ( <array-spec> ) 1450 [ , <array-name> ( <array-spec> ) ]... 1454 match = re.compile(
r"dimension\b", re.I).match
1456 def process_item(self):
1457 line = self.item.get_line()[9:].lstrip()
1458 if line.startswith(
"::"):
1459 line = line[2:].lstrip()
1460 self.items = split_comma(line, self.item)
1463 def tofortran(self, isfix=None):
1464 return self.get_indent_tab(isfix=isfix) +
"DIMENSION %s" % (
1465 ", ".join(self.items)
1469 for line
in self.items:
1471 assert i != -1
and line.endswith(
")"), repr(line)
1472 name = line[:i].rstrip()
1473 array_spec = split_comma(line[i + 1 : -1].strip(), self.item)
1474 var = self.get_variable(name)
1475 var.set_bounds(array_spec)
1481 TARGET [ :: ] <object-name> ( <array-spec> ) 1482 [ , <object-name> ( <array-spec> ) ]... 1486 match = re.compile(
r"target\b", re.I).match
1488 def process_item(self):
1489 line = self.
item.get_line()[6:].lstrip()
1490 if line.startswith(
"::"):
1491 line = line[2:].lstrip()
1492 self.
items = split_comma(line, self.
item)
1495 def tofortran(self, isfix=None):
1499 for line
in self.
items:
1501 assert i != -1
and line.endswith(
")"), repr(line)
1502 name = line[:i].rstrip()
1503 array_spec = split_comma(line[i + 1 : -1].strip(), self.
item)
1505 var.set_bounds(array_spec)
1506 var.update(
"target")
1512 POINTER [ :: ] <pointer-decl-list> 1513 <pointer-decl> = <object-name> [ ( <deferred-shape-spec-list> ) ] 1514 | <proc-entity-name> 1518 match = re.compile(
r"pointer\b", re.I).match
1520 def process_item(self):
1521 line = self.
item.get_line()[7:].lstrip()
1522 if line.startswith(
"::"):
1523 line = line[2:].lstrip()
1524 self.
items = split_comma(line, self.
item)
1527 def tofortran(self, isfix=None):
1531 for line
in self.
items:
1537 assert line.endswith(
")"), repr(line)
1538 name = line[:i].rstrip()
1539 array_spec = split_comma(line[i + 1 : -1].strip(), self.
item)
1541 var.set_bounds(array_spec)
1542 var.update(
"pointer")
1548 PROTECTED [ :: ] <entity-name-list> 1551 match = re.compile(
r"protected\b", re.I).match
1554 for name
in self.
items:
1556 var.update(
"protected")
1562 VOLATILE [ :: ] <object-name-list> 1565 match = re.compile(
r"volatile\b", re.I).match
1568 for name
in self.
items:
1570 var.update(
"volatile")
1576 VALUE [ :: ] <dummy-arg-name-list> 1579 match = re.compile(
r"value\b", re.I).match
1582 for name
in self.
items:
1590 IF ( <scalar-numeric-expr> ) <label> , <label> , <label> 1593 match = re.compile(
r"if\s*\(.*\)\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\Z", re.I).match
1595 def process_item(self):
1596 line = self.
item.get_line()[2:].lstrip()
1597 line, l2, l3 = line.rsplit(
",", 2)
1598 i = line.rindex(
")")
1600 self.
expr = self.
item.apply_map(line[1:i]).strip()
1601 self.
labels = [l1.strip(), l2.strip(), l3.strip()]
1604 def tofortran(self, isfix=None):
1614 class Intrinsic(StatementWithNamelist):
1616 INTRINSIC [ :: ] <intrinsic-procedure-name-list> 1619 match = re.compile(
r"intrinsic\b", re.I).match
1622 for name
in self.items:
1623 var = self.get_variable(name)
1624 var.update(
"intrinsic")
1630 INQUIRE ( <inquire-spec-list> ) 1631 INQUIRE ( IOLENGTH = <scalar-int-variable> ) <output-item-list> 1633 <inquire-spec> = [ UNIT = ] <file-unit-number> 1634 | FILE = <file-name-expr> 1636 <output-item> = <expr> 1640 match = re.compile(
r"inquire\s*\(", re.I).match
1642 def process_item(self):
1643 line = self.
item.get_line()[7:].lstrip()
1645 self.
specs = specs_split_comma(line[1:i].strip(), self.
item)
1646 self.
items = split_comma(line[i + 1 :].lstrip(), self.
item)
1649 def tofortran(self, isfix=None):
1652 ", ".join(self.
specs),
1653 ", ".join(self.
items),
1656 ", ".join(self.
specs)
1663 class Sequence(Statement):
1668 match = re.compile(
r"sequence\Z", re.I).match
1670 def process_item(self):
1673 def tofortran(self, isfix=None):
1674 return self.get_indent_tab(isfix=isfix) +
"SEQUENCE" 1677 self.parent.update_attributes(
"SEQUENCE")
1683 EXTERNAL [ :: ] <external-name-list> 1686 match = re.compile(
r"external\b", re.I).match
1689 for name
in self.
items:
1691 var.update(
"external")
1697 NAMELIST / <namelist-group-name> / <namelist-group-object-list> [ [ , ] 1698 / <namelist-group-name> / <namelist-group-object-list> ]... 1699 <namelist-group-object> = <variable-name> 1702 match = re.compile(
r"namelist\b", re.I).match
1704 def process_item(self):
1705 line = self.
item.get_line()[8:].lstrip()
1708 assert line.startswith(
"/"), repr(line)
1709 i = line.find(
"/", 1)
1710 assert i != -1, repr(line)
1711 name = line[: i + 1]
1712 line = line[i + 1 :].lstrip()
1715 items.append((name, line))
1718 s = line[:i].rstrip()
1721 items.append((name, s))
1722 line = line[i + 1 :].lstrip()
1726 def tofortran(self, isfix=None):
1728 for name, s
in self.
items:
1729 bits.append(
"%s %s" % (name, s))
1731 return tab +
"NAMELIST " +
", ".join(bits)
1736 COMMON [ / [ <common-block-name> ] / ] <common-block-object-list> \ 1737 [ [ , ] / [ <common-block-name> ] / <common-block-object-list> ]... 1738 <common-block-object> = <variable-name> [ ( <explicit-shape-spec-list> ) ] 1739 | <proc-pointer-name> 1742 match = re.compile(
r"common\b", re.I).match
1744 def process_item(self):
1746 line = item.get_line()[6:].lstrip()
1749 if not line.startswith(
"/"):
1751 assert not items, repr(line)
1753 i = line.find(
"/", 1)
1754 assert i != -1, repr(line)
1755 name = line[1:i].strip()
1756 line = line[i + 1 :].lstrip()
1759 items.append((name, split_comma(line, item)))
1762 s = line[:i].rstrip()
1765 items.append((name, split_comma(s, item)))
1766 line = line[i:].lstrip()
1770 def tofortran(self, isfix=None):
1772 for name, s
in self.
items:
1775 bits.append(
"/ %s / %s" % (name, s))
1779 return tab +
"COMMON " +
" ".join(bits)
1782 for cname, items
in self.
items:
1786 assert item.endswith(
")"), repr(item)
1787 name = item[:i].rstrip()
1788 shape = split_comma(item[i + 1 : -1].strip(), self.
item)
1793 if shape
is not None:
1794 var.set_bounds(shape)
1801 OPTIONAL [ :: ] <dummy-arg-name-list> 1802 <dummy-arg-name> = <name> 1805 match = re.compile(
r"optional\b", re.I).match
1808 for name
in self.
items:
1810 var.update(
"optional")
1816 INTENT ( <intent-spec> ) [ :: ] <dummy-arg-name-list> 1817 <intent-spec> = IN | OUT | INOUT 1819 generalization for pyf-files: 1820 INTENT ( <intent-spec-list> ) [ :: ] <dummy-arg-name-list> 1821 <intent-spec> = IN | OUT | INOUT | CACHE | HIDE | OUT = <name> 1824 match = re.compile(
r"intent\s*\(", re.I).match
1826 def process_item(self):
1827 line = self.
item.get_line()[6:].lstrip()
1829 self.
specs = specs_split_comma(line[1:i], self.
item, upper=
True)
1830 line = line[i + 1 :].lstrip()
1831 if line.startswith(
"::"):
1832 line = line[2:].lstrip()
1833 self.
items = [s.strip()
for s
in line.split(
",")]
1834 for n
in self.
items:
1840 def tofortran(self, isfix=None):
1842 ", ".join(self.
specs),
1843 ", ".join(self.
items),
1847 for name
in self.
items:
1849 var.set_intent(self.
specs)
1855 ENTRY <entry-name> [ ( [ <dummy-arg-list> ] ) [ <suffix> ] ] 1856 <suffix> = <proc-language-binding-spec> [ RESULT ( <result-name> ) ] 1857 | RESULT ( <result-name> ) [ <proc-language-binding-spec> ] 1858 <proc-language-binding-spec> = <language-binding-spec> 1859 <language-binding-spec> = 1860 BIND ( C [ , NAME = <scalar-char-initialization-expr> ] ) 1861 <dummy-arg> = <dummy-arg-name> | * 1864 match = re.compile(
r"entry\s+[a-zA-Z]", re.I).match
1866 def process_item(self):
1867 line = self.
item.get_line()[5:].lstrip()
1868 m = re.match(
r"\w+", line)
1869 name = line[: m.end()]
1870 line = line[m.end() :].lstrip()
1871 if line.startswith(
"("):
1873 assert i != -1, repr(line)
1874 items = split_comma(line[1:i], self.
item)
1875 line = line[i + 1 :].lstrip()
1878 self.bind, line = parse_bind(line, self.
item)
1879 self.result, line = parse_result(line, self.
item)
1881 assert self.bind
is None, repr(self.bind)
1882 self.bind, line = parse_bind(line, self.
item)
1883 assert not line, repr(line)
1888 def tofortran(self, isfix=None):
1890 s = tab +
"ENTRY " + self.
name 1892 s +=
" (%s)" % (
", ".join(self.
items))
1894 s +=
" RESULT (%s)" % (self.result)
1896 s +=
" BIND (%s)" % (
", ".join(self.bind))
1902 IMPORT [ [ :: ] <import-name-list> ] 1905 match = re.compile(
r"import(\b|\Z)", re.I).match
1910 FORALL <forall-header> <forall-assignment-stmt> 1911 <forall-header> = ( <forall-triplet-spec-list> [ , <scalar-mask-expr> ] ) 1912 <forall-triplet-spec> = 1913 <index-name> = <subscript> : <subscript> [ : <stride> ] 1914 <subscript|stride> = <scalar-int-expr> 1915 <forall-assignment-stmt> = <assignment-stmt> | <pointer-assignment-stmt> 1918 match = re.compile(
r"forall\s*\(.*\).*=", re.I).match
1920 def process_item(self):
1921 line = self.
item.get_line()[6:].lstrip()
1925 line = line[i + 1 :].lstrip()
1935 for l
in split_comma(line0, self.
item):
1938 assert not mask, repr((mask, l))
1941 assert j != -1, repr(l)
1942 index = l[:j].rstrip()
1943 it = self.
item.copy(l[j + 1 :].lstrip())
1944 line = it.get_line()
1948 map(it.apply_map, [k[0].strip(), k[1].strip(), k[2].strip()])
1951 assert len(k) == 2, repr(k)
1952 s1, s2 = list(map(it.apply_map, [k[0].strip(), k[1].strip()]))
1954 specs.append((index, s1, s2, s3))
1960 def tofortran(self, isfix=None):
1963 for index, s1, s2, s3
in self.
specs:
1964 s =
"%s = %s : %s" % (index, s1, s2)
1968 s =
", ".join(lines)
1970 s +=
", " + self.
mask 1971 return tab +
"FORALL (%s) %s" % (s, str(self.
content[0]).lstrip())
1982 PROCEDURE [ ( <interface-name> ) ] [ [ , <binding-attr-list> ] :: ] 1983 <binding-name> [ => <procedure-name> ] 1984 <binding-attr> = PASS [ ( <arg-name> ) ] 1989 <access-spec> = PUBLIC | PRIVATE 1993 match = re.compile(
r"procedure\b", re.I).match
1995 def process_item(self):
1996 line = self.
item.get_line()[9:].lstrip()
1997 if line.startswith(
"("):
1999 name = line[1:i].strip()
2000 line = line[i + 1 :].lstrip()
2004 if line.startswith(
","):
2005 line = line[1:].lstrip()
2008 attrs = split_comma(line[:i], self.
item)
2009 line = line[i + 2 :].lstrip()
2018 assert i != -1
and attr.endswith(
")"), repr(attr)
2019 attr =
"%s (%s)" % (attr[:i].rstrip().upper(), attr[i + 1 : -1].strip())
2027 self.
name = line[:i].rstrip()
2028 self.
bname = line[i + 1 :].lstrip()[1:].lstrip()
2031 def tofortran(self, isfix=None):
2035 s +=
"(" + self.
iname +
") " 2037 s +=
", " +
", ".join(self.
attrs) +
" :: " 2039 s +=
"%s => %s" % (self.
name, self.
bname)
2047 GENERIC [ , <access-spec> ] :: <generic-spec> => <binding-name-list> 2051 match = re.compile(
r"generic\b.*::.*=>.*\Z", re.I).match
2053 def process_item(self):
2054 line = self.
item.get_line()[7:].lstrip()
2055 if line.startswith(
","):
2056 line = line[1:].lstrip()
2057 i = line.index(
"::")
2058 self.
aspec = line[:i].rstrip().upper()
2059 line = line[i + 2 :].lstrip()
2060 i = line.index(
"=>")
2061 self.
spec = self.
item.apply_map(line[:i].rstrip())
2062 self.
items = split_comma(line[i + 2 :].lstrip())
2065 def tofortran(self, isfix=None):
2069 s +=
", " + self.
aspec 2070 s +=
" :: " + self.
spec +
" => " +
", ".join(self.
items)
2076 FINAL [ :: ] <final-subroutine-name-list> 2081 match = re.compile(
r"final\b", re.I).match
2086 ALLOCATABLE [ :: ] <object-name> [ ( <deferred-shape-spec-list> ) ] 2088 [ ( <deferred-shape-spec-list> ) ] 2093 match = re.compile(
r"allocatable\b", re.I).match
2095 def process_item(self):
2096 line = self.
item.get_line()[11:].lstrip()
2097 if line.startswith(
"::"):
2098 line = line[2:].lstrip()
2099 self.
items = split_comma(line, self.
item)
2102 def tofortran(self, isfix=None):
2106 for line
in self.
items:
2112 assert line.endswith(
")")
2113 name = line[:i].rstrip()
2114 array_spec = split_comma(line[i + 1 : -1], self.
item)
2116 var.update(
"allocatable")
2117 if array_spec
is not None:
2118 var.set_bounds(array_spec)
2124 ASYNCHRONOUS [ :: ] <object-name-list> 2127 match = re.compile(
r"asynchronous\b", re.I).match
2130 for name
in self.
items:
2132 var.update(
"asynchronous")
2138 <language-binding-spec> [ :: ] <bind-entity-list> 2139 <language-binding-spec> = 2140 BIND ( C [ , NAME = <scalar-char-initialization-expr> ] ) 2141 <bind-entity> = <entity-name> | / <common-block-name> / 2145 match = re.compile(
r"bind\s*\(.*\)", re.I).match
2147 def process_item(self):
2148 line = self.
item.line
2149 self.specs, line = parse_bind(line, self.
item)
2150 if line.startswith(
"::"):
2151 line = line[2:].lstrip()
2153 for item
in split_comma(line, self.
item):
2154 if item.startswith(
"/"):
2155 assert item.endswith(
"/"), repr(item)
2156 item =
"/ " + item[1:-1].strip() +
" /" 2161 def tofortran(self, isfix=None):
2163 ", ".join(self.specs),
2164 ", ".join(self.
items),
2173 ELSE [<if-construct-name>] 2176 match = re.compile(
r"else\b\s*\w*\s*\Z", re.I).match
2178 def process_item(self):
2180 self.
name = item.get_line()[4:].strip()
2181 parent_name = getattr(self.
parent,
"name",
"")
2182 if self.
name and self.
name != parent_name:
2184 "expected if-construct-name %r but got %r, skipping." 2185 % (parent_name, self.
name)
2190 def tofortran(self, isfix=None):
2199 class ElseIf(Statement):
2201 ELSE IF ( <scalar-logical-expr> ) THEN [ <if-construct-name> ] 2204 match = re.compile(
r"else\s*if\s*\(.*\)\s*then\s*\w*\s*\Z", re.I).match
2206 def process_item(self):
2208 line = item.get_line()[4:].lstrip()[2:].lstrip()
2210 assert line[0] ==
"(" 2211 self.expr = item.apply_map(line[1:i])
2212 self.name = line[i + 1 :].lstrip()[4:].strip()
2213 parent_name = getattr(self.parent,
"name",
"")
2214 if self.name
and self.name != parent_name:
2216 "expected if-construct-name %r but got %r, skipping." 2217 % (parent_name, self.name)
2219 self.isvalid =
False 2222 def tofortran(self, isfix=None):
2226 return self.get_indent_tab(deindent=
True) +
"ELSE IF (%s) THEN%s" % (
2238 class Case(Statement):
2240 CASE <case-selector> [ <case-construct-name> ] 2241 <case-selector> = ( <case-value-range-list> ) | DEFAULT 2242 <case-value-range> = <case-value> 2245 | <case-value> : <case-value> 2246 <case-value> = <scalar-(int|char|logical)-initialization-expr> 2250 match = re.compile(
r"case\b\s*(\(.*\)|DEFAULT)\s*\w*\Z", re.I).match
2253 """Populate the state of this item by parsing the associated line 2255 line = self.
item.get_line()[4:].lstrip()
2257 self.
items = extract_bracketed_list_items(line, self.
item)
2258 idx = line.rfind(
")")
2259 self.
name = line[idx + 1 :].lstrip()
2262 if not line.lower().startswith(
"default"):
2266 "Internal error when parsing CASE statement: {0}".format(line)
2271 self.
name = line[7:].lstrip()
2272 parent_name = getattr(self.
parent,
"name",
"")
2273 if self.
name and self.
name != parent_name:
2275 "Expected case-construct-name {0} but got {1}, " 2276 "skipping.".format(parent_name, self.
name)
2282 """Return the Fortran for this object as a string""" 2287 for item
in self.
items:
2288 lst.append((
" : ".join(item)).strip())
2289 txt +=
" ( %s )" % (
", ".join(lst))
2293 txt +=
" " + self.
name 2300 class TypeIs(Statement):
2302 TYPE IS <type-selector> [ <case-construct-name> ] 2303 <type-selector> = ( <type-value-range-list> ) 2304 <type-value-range> = <case-value> 2305 <case-value> = <char> 2308 match = re.compile(
r"type\b\s*is\b\s*\(.*\)\s*\w*\Z", re.I).match
2311 """Populate the state of this object by parsing the associated 2313 line = self.
item.get_line()
2318 self.
items = extract_bracketed_list_items(line, self.
item)
2320 idx2 = line.rfind(
")")
2321 self.
name = line[idx2 + 1 :].lstrip()
2322 parent_name = getattr(self.
parent,
"name",
"")
2323 if self.
name and self.
name != parent_name:
2325 "expected type-is-construct-name %r but got %r, skipping." 2326 % (parent_name, self.
name)
2332 """Create the Fortran representation of this object and return 2335 text = tab +
"TYPE IS" 2338 for item
in self.
items:
2339 lst.append((
" : ".join(item)).strip())
2340 text +=
" ( %s )" % (
", ".join(lst))
2342 raise ParseError(
"TYPE IS construct must have arguments")
2344 text +=
" " + self.
name 2351 class ClassIs(Statement):
2353 CLASS <class-selector> 2354 <class-selector> = ( IS <type-value-range-list> | DEFAULT ) 2355 <type-value-range> = <case-value> 2356 <case-value> = <char> 2359 match = re.compile(
r"class\b\s*(is\b\s*\(.*\)|default)\s*\w*\Z", re.I).match
2362 """Populate the state of this object by parsing the string""" 2363 line = self.
item.get_line()[5:].lstrip()
2365 self.
items = extract_bracketed_list_items(line, self.
item)
2370 idx = line.rfind(
")")
2371 self.
name = line[idx + 1 :].lstrip()
2374 if not line.lower().startswith(
"default"):
2378 "Internal error when parsing CLASS statement: {0}".format(line)
2383 self.
name = line[7:].lstrip()
2384 parent_name = getattr(self.
parent,
"name",
"")
2385 if self.
name and self.
name != parent_name:
2387 "expected class-construct-name %r but got %r, skipping." 2388 % (parent_name, self.
name)
2394 """Returns the Fortran for this object as a string""" 2396 text = tab +
"CLASS" 2400 for item
in self.
items:
2401 lchar.append((
" : ".join(item)).strip())
2402 text +=
" ( %s )" % (
", ".join(lchar))
2406 text +=
" " + self.
name 2416 class Where(Statement):
2418 WHERE ( <mask-expr> ) <where-assignment-stmt> 2421 match = re.compile(
r"where\s*\(.*\)\s*\w.*\Z", re.I).match
2423 def process_item(self):
2424 line = self.item.get_line()[5:].lstrip()
2426 self.expr = self.item.apply_map(line[1:i].strip())
2427 line = line[i + 1 :].lstrip()
2428 newitem = self.item.copy(line)
2431 stmt = cls(self, newitem)
2433 self.content = [stmt]
2435 self.isvalid =
False 2438 def tofortran(self, isfix=None):
2439 tab = self.get_indent_tab(isfix=isfix)
2440 return tab +
"WHERE ( %s ) %s" % (self.expr, str(self.content[0]).lstrip())
2451 ELSE WHERE ( <mask-expr> ) [ <where-construct-name> ] 2452 ELSE WHERE [ <where-construct-name> ] 2455 match = re.compile(
r"else\s*where\b", re.I).match
2457 def process_item(self):
2458 line = self.
item.get_line()[4:].lstrip()[5:].lstrip()
2460 if line.startswith(
"("):
2462 assert i != -1, repr(line)
2463 self.
expr = self.
item.apply_map(line[1:i].strip())
2464 line = line[i + 1 :].lstrip()
2466 parent_name = getattr(self.
parent,
"name",
"")
2467 if self.
name and not self.
name == parent_name:
2469 "expected where-construct-name %r but got %r, " 2470 "skipping." % (parent_name, self.
name)
2475 def tofortran(self, isfix=None):
2478 if self.
expr is not None:
2479 s +=
" ( %s )" % (self.
expr)
2481 s +=
" " + self.
name 2491 class Enumerator(Statement):
2493 ENUMERATOR [ :: ] <enumerator-list> 2494 <enumerator> = <named-constant> [ = <scalar-int-initialization-expr> ] 2497 match = re.compile(
r"enumerator\b", re.I).match
2499 def process_item(self):
2500 line = self.item.get_line()[10:].lstrip()
2501 if line.startswith(
"::"):
2502 line = line[2:].lstrip()
2503 self.items = split_comma(line, self.item)
2506 def tofortran(self, isfix=None):
2507 return self.get_indent_tab(isfix=isfix) +
"ENUMERATOR " +
", ".join(self.items)
2518 match = re.compile(
r"fortranname\s*\w+\Z", re.I).match
2520 def process_item(self):
2521 self.
value = self.
item.get_line()[11:].lstrip()
2524 def tofortran(self, isfix=None):
2533 match = re.compile(
r"threadsafe\Z", re.I).match
2535 def process_item(self):
2538 def tofortran(self, isfix=None):
2539 return self.get_indent_tab(isfix=isfix) +
"THREADSAFE" 2544 DEPEND ( <name-list> ) [ :: ] <dummy-arg-name-list> 2548 match = re.compile(
r"depend\s*\(", re.I).match
2550 def process_item(self):
2551 line = self.
item.get_line()[6:].lstrip()
2553 self.
depends = split_comma(line[1:i].strip(), self.
item)
2554 line = line[i + 1 :].lstrip()
2555 if line.startswith(
"::"):
2556 line = line[2:].lstrip()
2557 self.
items = split_comma(line)
2560 def tofortran(self, isfix=None):
2563 ", ".join(self.
items),
2569 CHECK ( <c-int-scalar-expr> ) [ :: ] <name> 2573 match = re.compile(
r"check\s*\(", re.I).match
2575 def process_item(self):
2576 line = self.
item.get_line()[5:].lstrip()
2578 assert i != -1, repr(line)
2579 self.
expr = self.
item.apply_map(line[1:i].strip())
2580 line = line[i + 1 :].lstrip()
2581 if line.startswith(
"::"):
2582 line = line[2:].lstrip()
2586 def tofortran(self, isfix=None):
2595 CALLSTATEMENT <c-expr> 2598 match = re.compile(
r"callstatement\b", re.I).match
2600 def process_item(self):
2601 self.
expr = self.
item.apply_map(self.
item.get_line()[13:].lstrip())
2604 def tofortran(self, isfix=None):
2610 CALLPROTOARGUMENT <c-type-spec-list> 2613 match = re.compile(
r"callprotoargument\b", re.I).match
2615 def process_item(self):
2616 self.
specs = self.
item.apply_map(self.
item.get_line()[17:].lstrip())
2619 def tofortran(self, isfix=None):
2628 PAUSE [ <char-literal-constant|int-literal-constant> ] 2631 match = re.compile(
r'pause\s*(\d+|\'\w*\'|"\w*"|)\Z', re.I).match
2633 def process_item(self):
2634 self.
value = self.
item.apply_map(self.
item.get_line()[5:].lstrip())
2637 def tofortran(self, isfix=None):
2646 class Comment(Statement):
2652 Content of the comment. 2654 When True then Comment represents blank line. 2658 match =
lambda s:
True 2660 def process_item(self):
2661 assert self.item.comment.count(
"\n") <= 1, repr(self.item)
2662 stripped = self.item.comment.lstrip()
2663 self.is_blank =
not stripped
2664 self.content = stripped[1:]
if stripped
else "" 2666 def tofortran(self, isfix=None):
2670 tab =
"C" + self.get_indent_tab(isfix=isfix)[1:]
2672 tab = self.get_indent_tab(isfix=isfix) +
"!" 2673 return tab + self.content
def tofortran(self, isfix=None)
def get_indent_tab(self, deindent=False, isfix=None)
def tofortran(self, isfix=None)
def populate_use_provides(self, all_mod_provides, use_provides, name, rename=None)
def tofortran(self, isfix=None)
def tofortran(self, isfix=None)
def tofortran(self, isfix=None)
def tofortran(self, isfix=None)
def get_variable(self, name)
def warning(self, message)