Attempts to match the supplied `string` with `lhs_cls` = `rhs_cls`.
If `lhs_cls` is a str then it is compared with the content to the
left of the first '=' character in `string`. If that content is a
valid Fortran name but does *not* match `lhs_cls` then the match
fails, irrespective of the setting of `require_lhs`.
:param lhs_cls: list, tuple or single value of classes to attempt to \
match LHS against (in order), or string containing \
keyword to match.
:type lhs_cls: names of classes deriving from `:py:class:Base` or str
:param rhs_cls: name of class to match RHS against.
:type rhs_cls: name of a class deriving from `:py:class:Base`
:param str string: text to be matched.
:param bool require_lhs: whether the expression to be matched must \
contain a LHS that is assigned to.
:param bool upper_lhs: whether or not to convert the LHS of the \
matched expression to upper case.
:return: instances of the classes representing quantities on the LHS \
and RHS (LHS is optional) or None if no match is found.
:rtype: 2-tuple of objects or NoneType
Definition at line 1133 of file utils.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.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.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.
1133 def match(lhs_cls, rhs_cls, string, require_lhs=True, upper_lhs=False):
1135 Attempts to match the supplied `string` with `lhs_cls` = `rhs_cls`. 1136 If `lhs_cls` is a str then it is compared with the content to the 1137 left of the first '=' character in `string`. If that content is a 1138 valid Fortran name but does *not* match `lhs_cls` then the match 1139 fails, irrespective of the setting of `require_lhs`. 1141 :param lhs_cls: list, tuple or single value of classes to attempt to \ 1142 match LHS against (in order), or string containing \ 1144 :type lhs_cls: names of classes deriving from `:py:class:Base` or str 1145 :param rhs_cls: name of class to match RHS against. 1146 :type rhs_cls: name of a class deriving from `:py:class:Base` 1147 :param str string: text to be matched. 1148 :param bool require_lhs: whether the expression to be matched must \ 1149 contain a LHS that is assigned to. 1150 :param bool upper_lhs: whether or not to convert the LHS of the \ 1151 matched expression to upper case. 1153 :return: instances of the classes representing quantities on the LHS \ 1154 and RHS (LHS is optional) or None if no match is found. 1155 :rtype: 2-tuple of objects or NoneType 1158 if require_lhs
and "=" not in string:
1160 if isinstance(lhs_cls, (list, tuple)):
1162 obj = KeywordValueBase.match(
1163 cls, rhs_cls, string, require_lhs=require_lhs, upper_lhs=upper_lhs
1172 pieces = string.split(
"=", 1)
1174 if len(pieces) == 2:
1177 lhs = pieces[0].strip()
1178 if isinstance(lhs_cls, str):
1193 rhs = string.strip()
1195 rhs = pieces[-1].strip()