fparser Reference Guide  0.0.14
fparser.two.C99Preprocessor.Cpp_If_Stmt Class Reference
Inheritance diagram for fparser.two.C99Preprocessor.Cpp_If_Stmt:
Collaboration diagram for fparser.two.C99Preprocessor.Cpp_If_Stmt:

Public Member Functions

def tostr (self)
 
- Public Member Functions inherited from fparser.two.utils.WORDClsBase
def tostr (self)
 
def tostr_a (self)
 
- Public Member Functions inherited from fparser.two.utils.Base
def __init__ (self, string, parent_cls=None)
 
def __new__ (cls, string, parent_cls=None)
 
def get_root (self)
 
def children (self)
 
def init (self, items)
 
def torepr (self)
 
def __str__ (self)
 
def __repr__ (self)
 
def tofortran (self, tab="", isfix=None)
 
def restore_reader (self, reader)
 
- Public Member Functions inherited from fparser.two.utils.ComparableMixin
def __lt__ (self, other)
 
def __le__ (self, other)
 
def __eq__ (self, other)
 
def __ge__ (self, other)
 
def __gt__ (self, other)
 
def __ne__ (self, other)
 

Static Public Member Functions

def match (string)
 
- Static Public Member Functions inherited from fparser.two.utils.WORDClsBase
def match (keyword, cls, string, colons=False, require_cls=False)
 

Static Public Attributes

 subclass_names
 
 use_names
 
 value
 
- Static Public Attributes inherited from fparser.two.utils.Base
 subclasses
 

Additional Inherited Members

- Public Attributes inherited from fparser.two.utils.Base
 parent
 
 items
 

Detailed Description

C99 6.10.1 Conditional inclusion

if-stmt is  # if constant-expression new-line
            or ifdef identifier new-line
            or ifndef identifier new-line

Definition at line 150 of file C99Preprocessor.py.

Member Function Documentation

◆ match()

def fparser.two.C99Preprocessor.Cpp_If_Stmt.match (   string)
static
Implements the matching for an if preprocessor directive
(or its variations ifdef, ifndef). For ifdef and ifndef
statements it matches the macro identifier using
:py:class:`fparser.two.C99Preprocesser.Cpp_Macro_Identifier`
otherwise it uses :py:class:`fparser.two.C99Preprocessor.Cpp_Pp_Tokens`
to accept any non-empty string as rhs.

:param str string: the string to match with as an if statement.

:return: a tuple of size 2 containing the statement's keyword \
  and the right hand side, or `None` if there is no match.
:rtype: \
  (`str`, py:class:`fparser.two.C99Preprocessor.Cpp_Macro_Identifier`)\
  or (`str`, py:class:`fparser.two.C99Preprocessor.Cpp_Pp_Tokens`) \
  or `NoneType`

Definition at line 171 of file C99Preprocessor.py.

171  def match(string):
172  """Implements the matching for an if preprocessor directive
173  (or its variations ifdef, ifndef). For ifdef and ifndef
174  statements it matches the macro identifier using
175  :py:class:`fparser.two.C99Preprocesser.Cpp_Macro_Identifier`
176  otherwise it uses :py:class:`fparser.two.C99Preprocessor.Cpp_Pp_Tokens`
177  to accept any non-empty string as rhs.
178 
179  :param str string: the string to match with as an if statement.
180 
181  :return: a tuple of size 2 containing the statement's keyword \
182  and the right hand side, or `None` if there is no match.
183  :rtype: \
184  (`str`, py:class:`fparser.two.C99Preprocessor.Cpp_Macro_Identifier`)\
185  or (`str`, py:class:`fparser.two.C99Preprocessor.Cpp_Pp_Tokens`) \
186  or `NoneType`
187 
188  """
189  if not string:
190  return None
191  result = WORDClsBase.match(
192  Cpp_If_Stmt._if_pattern,
193  Cpp_Pp_Tokens,
194  string,
195  colons=False,
196  require_cls=True,
197  )
198  return result or WORDClsBase.match(
199  Cpp_If_Stmt._def_pattern,
200  Cpp_Macro_Identifier,
201  string,
202  colons=False,
203  require_cls=True,
204  )
205 
Here is the caller graph for this function:

◆ tostr()

def fparser.two.C99Preprocessor.Cpp_If_Stmt.tostr (   self)
:return: this if-stmt as a string.
:rtype: str

Definition at line 206 of file C99Preprocessor.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.

206  def tostr(self):
207  """
208  :return: this if-stmt as a string.
209  :rtype: str
210  """
211  return "{0} {1}".format(*self.items)
212 
213 
Here is the caller graph for this function:

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