Class encapsulating information about any Implicit statements
contained within a scoping block.
Definition at line 138 of file block_statements.py.
◆ get_type_by_name()
def fparser.one.block_statements.HasImplicitStmt.get_type_by_name |
( |
|
self, |
|
|
|
name |
|
) |
| |
Returns an object of the correct type (Integer or Real) using
Fortran's implicit typing rules for the supplied variable name.
:param str name: The variable name.
:returns: Object describing the variable.
:rtype: Either :py:class:`fparser.one.typedecl_statements.Real` \
or :py:class:`fparser.one.typedecl_statements.Integer`.
Definition at line 146 of file block_statements.py.
References fparser.one.block_statements.HasImplicitStmt.a, fparser.common.base_classes.Statement.a, fparser.two.Fortran2003.Comment.item, and fparser.common.base_classes.Statement.item.
146 def get_type_by_name(self, name):
148 Returns an object of the correct type (Integer or Real) using 149 Fortran's implicit typing rules for the supplied variable name. 151 :param str name: The variable name. 152 :returns: Object describing the variable. 153 :rtype: Either :py:class:`fparser.one.typedecl_statements.Real` \ 154 or :py:class:`fparser.one.typedecl_statements.Integer`. 159 implicit_rules = self.a.implicit_rules
160 if implicit_rules
is None:
162 "Implicit rules mapping is null " "while getting %r type" % (name)
164 line = name[0].lower()
165 if line
in implicit_rules:
166 return implicit_rules[line]
169 line =
"default_integer" 171 line =
"default_real" 172 var = implicit_rules.get(line,
None)
174 if line[8:] ==
"real":
175 implicit_rules[line] = var = Real(self, self.item.copy(
"real"))
177 implicit_rules[line] = var = Integer(self, self.item.copy(
"integer"))
◆ topyf()
def fparser.one.block_statements.HasImplicitStmt.topyf |
( |
|
self, |
|
|
|
tab = " " |
|
) |
| |
Constructs a pyf representation of this class.
:param str tab: White space to prepend to output.
:returns: pyf code for this implicit statement.
:rtype: str
Definition at line 180 of file block_statements.py.
References fparser.one.block_statements.HasImplicitStmt.a, and fparser.common.base_classes.Statement.a.
180 def topyf(self, tab=" "):
182 Constructs a pyf representation of this class. 184 :param str tab: White space to prepend to output. 185 :returns: pyf code for this implicit statement. 188 implicit_rules = self.a.implicit_rules
189 if implicit_rules
is None:
190 return tab +
"IMPLICIT NONE\n" 194 for char, itype
in list(implicit_rules.items()):
195 if char.startswith(
"default"):
197 type_str = itype.tostr()
198 if type_str
in items:
199 items[type_str].append(char)
201 items[type_str] = [char]
203 return tab +
"! default IMPLICIT rules apply\n" 206 for itype, letter_list
in list(items.items()):
208 impl_list.append(itype +
" (%s)" % (
", ".join(letter_list)))
209 stmt +=
" " +
", ".join(impl_list)
210 return tab + stmt +
"\n"
The documentation for this class was generated from the following file:
- /home/docs/checkouts/readthedocs.org/user_builds/fparser-ref/checkouts/342_reference_guide/src/fparser/one/block_statements.py