fparser Reference Guide  0.0.14
fparser.two.Fortran2003.Prefix Class Reference
Inheritance diagram for fparser.two.Fortran2003.Prefix:
Collaboration diagram for fparser.two.Fortran2003.Prefix:

Static Public Member Functions

def match (string)
 

Static Public Attributes

 subclass_names
 

Detailed Description

Fortran2003 rule R1227

prefix is prefix-spec [ prefix-spec ] ...

C1240 (R1227) A prefix shall contain at most one of each
prefix-spec. Checked below.

C1241 (R1227) A prefix shall not specify both ELEMENTAL and
RECURSIVE. Checked below.

C1242 (R1227) A prefix shall not specify ELEMENTAL if
proc-language-binding-spec appears in the function-stmt or
subroutine-stmt. This constraint can not be checked here, it is
checked in R1224 and R1232.

Definition at line 11697 of file Fortran2003.py.

Member Function Documentation

◆ match()

def fparser.two.Fortran2003.Prefix.match (   string)
static
Match a space separated list of Prefix_Spec objects. Objects may be
separated by 1 or more spaces.

:returns: A tuple of size 2 containing the separator and a \
tuple containing one or more Prefix_Spec objects if there is a \
match and None if not.

:rtype: (str, (:class:py:`fparser.two.Fortran2003.Prefix_Spec`,)) \
or NoneType

Definition at line 11718 of file Fortran2003.py.

11718  def match(string):
11719  """Match a space separated list of Prefix_Spec objects. Objects may be
11720  separated by 1 or more spaces.
11721 
11722  :returns: A tuple of size 2 containing the separator and a \
11723  tuple containing one or more Prefix_Spec objects if there is a \
11724  match and None if not.
11725 
11726  :rtype: (str, (:class:py:`fparser.two.Fortran2003.Prefix_Spec`,)) \
11727  or NoneType
11728 
11729  """
11730  start_match_list = []
11731  end_match_list = []
11732  decl_spec_list = []
11733  keyword_list = []
11734  split = string.split()
11735  # Match prefix-spec (apart from declaration-type-spec) from
11736  # the left end of the string. These can be tokenised with a
11737  # simple split as they are guaranteed to not contain any
11738  # whitespace (as they are keywords).
11739  while split and split[0].upper() in Prefix_Spec.keywords:
11740  start_match_list.append(Prefix_Spec(split[0]))
11741  keyword_list.append(split[0].upper())
11742  split = split[1:]
11743  # Match prefix-spec (apart from declaration-type-spec) from
11744  # the right end of the string.
11745  while split and split[-1].upper() in Prefix_Spec.keywords:
11746  end_match_list.insert(0, Prefix_Spec(split[-1]))
11747  keyword_list.append(split[-1].upper())
11748  split = split[:-1]
11749  # What is remaining must be a declaration-type-spec (or is
11750  # empty) as only one of each prefix-spec is allowed in a
11751  # prefix (C1240). This may contain internal white space so
11752  # join the remaining parts together.
11753  remaining = " ".join(split)
11754  if remaining:
11755  decl_spec_list = [Declaration_Type_Spec(remaining)]
11756  if len(set(keyword_list)) != len(keyword_list):
11757  # C1240 A prefix shall contain at most one of each
11758  # prefix-spec. No need to check declaration-type-spec as
11759  # that is limited to at most one by design.
11760  return None
11761  if "ELEMENTAL" in keyword_list and "RECURSIVE" in keyword_list:
11762  # C1241 A prefix shall not specify both ELEMENTAL and RECURSIVE.
11763  return None
11764  result_list = start_match_list + decl_spec_list + end_match_list
11765  if result_list:
11766  return " ", tuple(result_list)
11767  # A prefix must contain at least one prefix-spec.
11768  return None
11769 
11770 
Here is the caller graph for this function:

The documentation for this class was generated from the following file: