This class helps implement the matching for the first part of the
Fortran 2003 Constraint C1002 which constrains rule R1002. In
particular it matches with the subset of edit descriptors that can
follow a P edit descriptor without needing a comma, see below:
C1002 (applied to R1002) The comma used to separate format-items
in a format-item-list may be omitted
(1) Between a P edit descriptor and an immediately following F, E,
EN, ES, D, or G edit descriptor, possibly preceded by a
repeat specifier.
[Remaining constraint clauses ommitted as they are not relevant
here.]
data-edit-desc is F w . d
or E w . d [ E e ]
or EN w . d [ E e ]
or ES w . d [ E e]
or G w . d [ E e ]
or D w . d
Definition at line 9420 of file Fortran2003.py.
def fparser.two.Fortran2003.Data_Edit_Desc_C1002.match |
( |
|
string | ) |
|
|
static |
Check whether the input matches the rule.
param str string: contains the Fortran that we are trying to \
match.
:return: `None` if there is no match, otherwise a `tuple` of \
size 4, the first entry containing a string with one of ['F', \
'E', 'EN', 'ES', 'G', 'D'], the second entry containing a W \
class instance, the third entry containing D class instance \
and the fourth entry containing either None or an E class \
instance.
:rtype: `NoneType`, (`str`, :py:class:`fparser.two.W`, \
:py:class:`fparser.two.D`, `NoneType`) or, (`str`, \
:py:class:`fparser.two.W`, :py:class:`fparser.two.D`, \
:py:class:`fparser.two.E`)
Definition at line 9449 of file Fortran2003.py.
9450 """Check whether the input matches the rule. 9452 param str string: contains the Fortran that we are trying to \ 9454 :return: `None` if there is no match, otherwise a `tuple` of \ 9455 size 4, the first entry containing a string with one of ['F', \ 9456 'E', 'EN', 'ES', 'G', 'D'], the second entry containing a W \ 9457 class instance, the third entry containing D class instance \ 9458 and the fourth entry containing either None or an E class \ 9460 :rtype: `NoneType`, (`str`, :py:class:`fparser.two.W`, \ 9461 :py:class:`fparser.two.D`, `NoneType`) or, (`str`, \ 9462 :py:class:`fparser.two.W`, :py:class:`fparser.two.D`, \ 9463 :py:class:`fparser.two.E`) 9468 strip_string = string.strip()
9469 if not strip_string:
9471 char = strip_string[0].upper()
9472 if char
in [
"F",
"D"]:
9474 my_str = strip_string[1:].lstrip().upper()
9476 left, right = my_str.split(
".", 1)
9477 left = left.rstrip()
9478 right = right.lstrip()
9479 return char, W(left), D(right),
None 9481 if char
in [
"E",
"G"]:
9484 my_str = strip_string[1:].lstrip().upper()
9486 if char ==
"E" and char2
in [
"S",
"N"]:
9487 my_str = my_str[1:].lstrip()
9490 if "." not in my_str:
9492 left, right = my_str.split(
".", 1)
9493 left = left.rstrip()
9494 right = right.lstrip()
9497 if right.count(
"E") >= 1:
9498 middle, right = right.split(
"E", 1)
9499 middle = middle.rstrip()
9500 right = right.lstrip()
9501 return char + char2, W(left), D(middle), E(right)
9502 return char + char2, W(left), D(right),
None
def fparser.two.Fortran2003.Data_Edit_Desc_C1002.tostr |
( |
|
self | ) |
|
:return: parsed representation of a Data Edit Descriptor \
conforming to constraint C1002.
:rtype: str
:raises InternalError: if the length of the internal items \
list is not 4.
:raises InternalError: if the first, second or third entry of \
the internal items list has no content.
:raises InternalError: if the value of the first entry is \
unsupported.
:raises InternalError: if the value of the first entry is 'F' \
or 'D' and the fourth entry has content.
:raises InternalError: if the value of the first entry is 'E', \
'EN', 'ES' or 'G' and the fourth entry is empty or None.
Definition at line 9506 of file Fortran2003.py.
References fparser.two.Fortran2003.Comment.items, fparser.one.statements.StatementWithNamelist.items, fparser.one.statements.Assign.items, fparser.one.statements.Call.items, fparser.one.statements.ComputedGoto.items, fparser.one.statements.AssignedGoto.items, fparser.two.utils.Base.items, fparser.one.statements.Print.items, fparser.one.statements.Read0.items, fparser.one.statements.Read1.items, fparser.one.typedecl_statements.Implicit.items, fparser.one.statements.Write.items, fparser.one.statements.Allocate.items, fparser.one.statements.Deallocate.items, fparser.one.statements.ModuleProcedure.items, fparser.one.statements.Access.items, fparser.two.utils.SequenceBase.items, fparser.one.statements.Save.items, fparser.one.statements.Nullify.items, fparser.one.statements.Use.items, fparser.one.statements.Parameter.items, fparser.one.statements.Equivalence.items, fparser.one.statements.Dimension.items, fparser.one.statements.Target.items, fparser.one.statements.Pointer.items, fparser.two.utils.EndStmtBase.items, fparser.one.statements.Inquire.items, fparser.one.statements.Namelist.items, fparser.one.statements.Common.items, fparser.one.statements.Intent.items, fparser.one.statements.Entry.items, fparser.one.statements.GenericBinding.items, fparser.one.statements.Allocatable.items, fparser.one.statements.Bind.items, fparser.one.statements.Case.items, fparser.one.statements.TypeIs.items, fparser.one.statements.ClassIs.items, fparser.one.statements.Enumerator.items, and fparser.one.statements.Depend.items.
9508 :return: parsed representation of a Data Edit Descriptor \ 9509 conforming to constraint C1002. 9512 :raises InternalError: if the length of the internal items \ 9514 :raises InternalError: if the first, second or third entry of \ 9515 the internal items list has no content. 9516 :raises InternalError: if the value of the first entry is \ 9518 :raises InternalError: if the value of the first entry is 'F' \ 9519 or 'D' and the fourth entry has content. 9520 :raises InternalError: if the value of the first entry is 'E', \ 9521 'EN', 'ES' or 'G' and the fourth entry is empty or None. 9524 if not len(self.items) == 4:
9525 raise InternalError(
9526 "Class Data_Edit_Desc_C1002 method tostr() has '{0}' items, " 9527 "but expecting 4.".format(len(self.items))
9529 if not self.items[0]:
9530 raise InternalError(
9531 "items[0] in Class Data_Edit_Desc_C1002 method tostr() " 9532 "should be a descriptor name but is empty or None" 9534 if not self.items[1]:
9535 raise InternalError(
9536 "items[1] in Class Data_Edit_Desc_C1002 method tostr() " 9537 "should be the w value but is empty or None" 9539 if not self.items[2]:
9540 raise InternalError(
9541 "items[2] in Class Data_Edit_Desc_C1002 method tostr() " 9542 "should be the m value but is empty or None" 9544 descriptor_name = self.items[0]
9545 if descriptor_name
in [
"F",
"D"]:
9547 raise InternalError(
9548 "items[3] in Class Data_Edit_Desc_C1002 method tostr() " 9549 "has an exponent value '{0}' but this is not allowed for " 9550 "'F' and 'D' descriptors and should therefore be " 9551 "None".format(self.items[3])
9553 return "{0}{1}.{2}".format(descriptor_name, self.items[1], self.items[2])
9554 elif descriptor_name
in [
"E",
"EN",
"ES",
"G"]:
9555 if self.items[3]
is None:
9556 return "{0}{1}.{2}".format(
9557 descriptor_name, self.items[1], self.items[2]
9559 return "{0}{1}.{2}E{3}".format(
9560 descriptor_name, self.items[1], self.items[2], self.items[3]
9562 raise InternalError(
9563 "Unexpected descriptor name '{0}' in Class Data_Edit_Desc_C1002 " 9564 "method tostr()".format(descriptor_name)