loki.frontend.fparser
Module Attributes
Indicate whether fparser frontend is available.  | 
Functions
  | 
Extract the   | 
  | 
Extract child nodes with type given by   | 
  | 
Extract a subset of nodes from a list that sits between marked start and end nodes.  | 
  | 
Generate an internal IR from fparser parse tree  | 
  | 
Parse an expression string into an expression tree.  | 
  | 
Generate a parse tree from file via fparser  | 
  | 
Generate a parse tree from string  | 
  | 
Searches for the last, immediate child of the supplied node that is of the specified type.  | 
Classes
  | 
- HAVE_FP = True
 Indicate whether fparser frontend is available.
- class FParser2IR(raw_source, definitions=None, pp_info=None, scope=None)
 Bases:
GenericVisitor- static warn_or_fail(msg)
 
- get_source(o, source)
 Helper method that builds the source object for the node.
- get_block_source(start_node, end_node)
 Helper method that builds the source object for a block node.
- get_label(o)
 Helper method that returns the label of the node.
- visit(o, **kwargs)
 Generic dispatch method that tries to generate meta-data from source.
- visit_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Intrinsic_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Specification_Part(o, **kwargs)
 The specification part of a program-unit
fparser.two.Fortran2003.Specification_Parthas variable number of children making up the body of the spec.
- visit_Implicit_Part(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Program(o, **kwargs)
 The specification part of a program-unit
fparser.two.Fortran2003.Specification_Parthas variable number of children making up the body of the spec.
- visit_Execution_Part(o, **kwargs)
 The specification part of a program-unit
fparser.two.Fortran2003.Specification_Parthas variable number of children making up the body of the spec.
- visit_Internal_Subprogram_Part(o, **kwargs)
 The specification part of a program-unit
fparser.two.Fortran2003.Specification_Parthas variable number of children making up the body of the spec.
- visit_Module_Subprogram_Part(o, **kwargs)
 The specification part of a program-unit
fparser.two.Fortran2003.Specification_Parthas variable number of children making up the body of the spec.
- visit_Name(o, **kwargs)
 A symbol name
fparser.two.Fortran2003.Namehas no children.
- visit_Type_Name(o, **kwargs)
 A derived type name
fparser.two.Fortran2003.Type_Namehas no children.
- visit_Part_Ref(o, **kwargs)
 A part of a data ref (e.g., flat variable or array name, or name of a derived type variable or member) and, optionally, a subscript list
fparser.two.Fortran2003.Part_Refhas two children:fparser.two.Fortran2003.Name: the part namefparser.two.Fortran2003.Section_Subscript_List: the subscript (or None)
- visit_Data_Ref(o, **kwargs)
 A fully qualified name for accessing a derived type or class member, composed from individual
fparser.two.Fortran2003.Part_Refaspart-ref [% part-ref [% part-ref ...] ]fparser.two.Fortran2003.Data_Refhas variable number of children, depending on the number of part-ref.
- visit_Use_Stmt(o, **kwargs)
 An import of symbol names via
USEfparser.two.Fortran2003.Use_Stmthas five children:module-nature (str: ‘INTRINSIC’ or ‘NON_INTRINSIC’ or None if absent)
‘::’ (str) if a double colon is used, otherwise None
module-name
fparser.two.Fortran2003.Module_Name
followed by
‘, ONLY:’ (str) and
fparser.two.Fortran2003.Only_List, or‘,’ (str) and
fparser.two.Fortran2003.Rename_List, or‘’ (str) and no only-list or rename-list
- visit_Only_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Rename_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Rename(o, **kwargs)
 A rename of an imported symbol
fparser.two.Fortran2003.Renamehas three children:‘OPERATOR’ (str) or None
fparser.two.Fortran2003.Local_Nameorfparser.two.Fortran2003.Local_Defined_Operatorfparser.two.Fortran2003.Use_Nameorfparser.two.Fortran2003.Use_Defined_Operator
- visit_Type_Declaration_Stmt(o, **kwargs)
 Variable declaration statement
fparser.two.Fortran2003.Type_Declaration_Stmthas 3 children:fparser.two.Fortran2003.Declaration_Type_Spec(fparser.two.Fortran2003.Intrinsic_Type_Specorfparser.two.Fortran2003.Derived_Type_Spec)fparser.two.Fortran2003.Attr_Spec_Listfparser.two.Fortran2003.Entity_Decl_List
- visit_Intrinsic_Type_Spec(o, **kwargs)
 An intrinsic type
fparser.two.Fortran2003.Intrinsic_Type_Spechas 2 children:type name (str)
kind (
fparser.two.Fortran2003.Kind_Selector) or length (fparser.two.Fortran2003.Length_Selector)
- visit_Kind_Selector(o, **kwargs)
 A kind selector of an intrinsic type
fparser.two.Fortran2003.Kind_Selectorhas 2 or 3 children:'*'(str) andfparser.two.Fortran2003.Char_Length, or'('(str),fparser.two.Fortran2003.Scalar_Int_Initialization_Expr, and')'(str)
- visit_Length_Selector(o, **kwargs)
 A length selector for intrinsic character type
fparser.two.Fortran2003.Length_Selectorhas 3 children:‘(’ (str)
fparser.two.Fortran2003.Char_Lengthorfparser.two.Fortran2003.Type_Param_Value‘)’ (str)
- visit_Char_Length(o, **kwargs)
 Length specifier in the Length_Selector
fparser.two.Fortran2003.Length_Selectorhas one child:length value (str)
- visit_Char_Selector(o, **kwargs)
 Length- and kind-selector for intrinsic character type
fparser.two.Fortran2003.Char_Selectorhas 2 children:some scalar expression for the kind
- visit_Type_Param_Value(o, **kwargs)
 The value of a type parameter in a type spefication (such as length of a CHARACTER)
fparser.two.Fortran2003.Type_Param_Valuehas only 1 attribute:string: the value of the parameter (str)
- visit_Declaration_Type_Spec(o, **kwargs)
 A derived type specifier in a declaration
fparser.two.Fortran2003.Declaration_Type_Spechas 2 children:keyword ‘TYPE’ or ‘CLASS’ (str)
- visit_Dimension_Attr_Spec(o, **kwargs)
 The dimension specification as attribute in a declaration
fparser.two.Fortran2003.Dimensions_Attr_Spechas 2 children:attribute name (str)
- visit_Intent_Attr_Spec(o, **kwargs)
 The intent specification in a declaration
fparser.two.Fortran2003.Intent_Attr_Spechas 2 children:‘INTENT’ keyword
- visit_Attr_Spec_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Attr_Spec(o, **kwargs)
 A declaration attribute
fparser.two.Fortran2003.Attr_Spechas no children.
- visit_Access_Spec(o, **kwargs)
 A declaration attribute for access specification (PRIVATE, PUBLIC)
fparser.two.Fortran2003.Access_Spechas no children.
- visit_Entity_Decl_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Entity_Decl(o, **kwargs)
 A variable entity in a declaration
fparser.two.Fortran2003.Entity_Declhas 4 children:object name (
fparser.two.Fortran2003.Name)array spec (
fparser.two.Fortran2003.Array_Spec)char length (
fparser.two.Fortran2003.Char_Length)
- visit_Explicit_Shape_Spec(o, **kwargs)
 Explicit shape specification for arrays
fparser.two.Fortran2003.Explicit_Shape_Spechas 2 children:lower bound (if explicitly given)
upper bound
- visit_Explicit_Shape_Spec_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Assumed_Shape_Spec(o, **kwargs)
 Explicit shape specification for arrays
fparser.two.Fortran2003.Explicit_Shape_Spechas 2 children:lower bound (if explicitly given)
upper bound
- visit_Assumed_Shape_Spec_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Assumed_Size_Spec(o, **kwargs)
 Explicit shape specification for arrays
fparser.two.Fortran2003.Explicit_Shape_Spechas 2 children:lower bound (if explicitly given)
upper bound
- visit_Deferred_Shape_Spec(o, **kwargs)
 Explicit shape specification for arrays
fparser.two.Fortran2003.Explicit_Shape_Spechas 2 children:lower bound (if explicitly given)
upper bound
- visit_Deferred_Shape_Spec_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Initialization(o, **kwargs)
 Variable initialization in declaration
fparser.two.Fortran2003.Initializationhas 2 children:‘=’ or ‘=>’ (str)
init expr
- visit_Component_Initialization(o, **kwargs)
 Variable initialization in declaration
fparser.two.Fortran2003.Initializationhas 2 children:‘=’ or ‘=>’ (str)
init expr
- visit_External_Stmt(o, **kwargs)
 An
EXTERNALstatement to specify the external attribute for a list of namesfparser.two.Fortran2003.External_Stmthas 2 children:keyword ‘EXTERNAL (str)
the list of names
fparser.two.Fortran2003.External_Name_List
- visit_External_Name_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Access_Stmt(o, **kwargs)
 An access-spec statement that specifies accessibility of symbols in a module
faprser.two.Fortran2003.Access_Stmthas 2 children:keyword
PRIVATEorPUBLIC(str)optional list of names (
fparser.two.Fortran2003.Access_Id_List) or None
- visit_Procedure_Declaration_Stmt(o, **kwargs)
 Procedure declaration statement
fparser.two.Fortran2003.Procedure_Declaration_Stmthas 3 children:fparser.two.Fortran2003.Name: the name of the procedure interfacefparser.two.Fortran2003.Proc_Attr_Spec_Listor None: the declared attributes (if any)fparser.two.Fortran2003.Proc_Decl_List: the local procedure names
- visit_Proc_Attr_Spec_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Proc_Attr_Spec(o, **kwargs)
 Procedure declaration attribute
fparser.two.Fortran2003.Proc_Attr_Spechas 2 children:attribute name (str)
attribute value (such as
IN,OUT,INOUT) or None
- visit_Proc_Decl_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Proc_Decl(o, **kwargs)
 A symbol entity in a procedure declaration with initialization
fparser.two.Fortran2003.Proc_Declhas 3 children:object name (
fparser.two.Fortran2003.Name)operator
=>(str)initializer (
fparser.two.Fortran2003.Function_Reference)
- visit_Array_Constructor(o, **kwargs)
 An array constructor expression
fparser.two.Fortran2003.Array_Constructorhas three children:left bracket (str):
(/or[the spec:
fparser.two.Fortran2003.Ac_Specright bracket (str):
/)or]
- visit_Ac_Spec(o, **kwargs)
 The spec in an array constructor
fparser.two.Fortran2003.Ac_Spechas two children: *fparser.two.Fortran2003.Type_Specor None *fparser.two.Fortran2003.Ac_Value_List
- visit_Ac_Value_List(o, **kwargs)
 The list of values in an array constructor
- visit_Ac_Implied_Do(o, **kwargs)
 An implied-do for array constructors
fparser.two.Fortran2003.Ac_Implied_Dohas two children: * the expression asfparser.two.Fortran2003.Ac_Value_List* the loop control asfparser.two.Fortran2003.Ac_Implied_Do_Control
- visit_Ac_Implied_Do_Control(o, **kwargs)
 The “loop control” for an implied-do
fparser.two.Fortran2003.Ac_Implied_Do_Controlhas two children: * the variable name * the loop bounds
- visit_Data_Stmt(o, **kwargs)
 A
DATAstatementfparser.two.Fortran2003.Data_Stmthas variable number of childrenfparser.two.Fortran2003.Data_Stmt_Set.
- visit_Data_Stmt_Set(o, **kwargs)
 A data-stmt-set in a data-stmt
fparser.two.Fortran2003.Data_Stmt_Sethas two children:the object to initialize
fparser.two.Fortran2003.Data_Stmt_Objectthe value list
fparser.two.Fortran2003.Data_Stmt_Value_List
- visit_Data_Implied_Do(o, **kwargs)
 An implied-do for data-stmt
- visit_Data_Stmt_Object_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Data_Stmt_Value_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Data_Stmt_Value(o, **kwargs)
 A value in a data-stmt-set
fparser.two.Fortran2003.Data_Stmt_Valuehas two children:the repeat value
fparser.two.Fortran2003.Data_Stmt_Repeatthe constant
fparser.two.Fortran2003.Data_Stmt_Constant
- visit_Section_Subscript_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Subscript_Triplet(o, **kwargs)
 A subscript expression with
[start] : [stop] [: stride]fparser.two.Fortran2003.Subscript_Triplethas three children:start
fparser.two.Fortran2003.Subscriptor Nonestop
fparser.two.Fortran2003.Subscriptor Nonestride
fparser.two.Fortran2003.Strideor None
- visit_Array_Section(o, **kwargs)
 A subscript operation on a data-ref
This includes dereferences such as
a%b%cor extracting a substring. In practice, the first are typically flattened in the Fparser AST and directly returned as Part_Ref, so we should see only the substring operation here.fparser.two.Fortran2003.Array_Subscripthas two children:the subscript data-ref
fparser.two.Fortran2003.Data_Refan optional substring range
fparser.two.Fortran2003.Substring_Range
- visit_Substring_Range(o, **kwargs)
 The range of a substring operation
fparser.two.Fortran2003.Substring_Rangehas two children:start
fparser.two.Fortran2003.Scalar_Int_Expror Nonestop
fparser.two.Fortran2003.Scalar_Int_Expror None
- visit_Stride(o, **kwargs)
 
- visit_Derived_Type_Def(o, **kwargs)
 A derived type definition
fparser.two.Fortran2003.Derived_Type_Defhas variable number of children:header stmt (
fparser.two.Fortran2003.Derived_Type_Stmt)all of body (list of
fparser.two.Fortran2003.Type_Param_Def_Stmt,fparser.two.Fortran2003.Private_Or_Sequence,fparser.two.Fortran2003.Component_Part,fparser.two.Fortran2003.Type_Bound_Procedure_Part)end stmt (
fparser.two.Fortran2003.End_Type_Stmt)
- visit_Derived_Type_Stmt(o, **kwargs)
 The block header for the derived type definition
fparser.two.Fortran2003.Derived_Type_Stmthas 3 children:attribute spec list (
fparser.two.Fortran2003.Type_Attr_Spec_List)type name (
fparser.two.Fortran2003.Type_Name)parameter name list (
fparser.two.Fortran2003.Type_Param_Name_List)
- visit_Type_Attr_Spec_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Type_Attr_Spec(o, **kwargs)
 A component declaration attribute
fparser.two.Fortran2003.Type_Attr_Spechas 2 children:keyword (str)
value (str) or None
- visit_Type_Param_Def_Stmt(o, **kwargs)
 
- visit_Binding_Attr_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Binding_Attr(o, **kwargs)
 A binding attribute
fparser.two.Fortran2003.Binding_Attr_Spechas no children
- visit_Binding_PASS_Arg_Name(o, **kwargs)
 Named PASS attribute
fparser.two.Fortran2003.Binding_PASS_Arg_Namehas two children:str: ‘PASS’
Name: the argument name
- visit_Component_Part(o, **kwargs)
 Derived type definition components
fparser.two.Fortran2003.Component_Parthas a list offparser.two.Fortran2003.Data_Component_Def_Stmtorfparser.two.Fortran2003.Proc_Component_Def_Stmtas children
- visit_Data_Component_Def_Stmt(o, **kwargs)
 Variable declaration statement
fparser.two.Fortran2003.Type_Declaration_Stmthas 3 children:fparser.two.Fortran2003.Declaration_Type_Spec(fparser.two.Fortran2003.Intrinsic_Type_Specorfparser.two.Fortran2003.Derived_Type_Spec)fparser.two.Fortran2003.Attr_Spec_Listfparser.two.Fortran2003.Entity_Decl_List
- visit_Component_Attr_Spec_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Component_Attr_Spec(o, **kwargs)
 A declaration attribute
fparser.two.Fortran2003.Attr_Spechas no children.
- visit_Dimension_Component_Attr_Spec(o, **kwargs)
 The dimension specification as attribute in a declaration
fparser.two.Fortran2003.Dimensions_Attr_Spechas 2 children:attribute name (str)
- visit_Component_Decl_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Component_Decl(o, **kwargs)
 A variable entity in a declaration
fparser.two.Fortran2003.Entity_Declhas 4 children:object name (
fparser.two.Fortran2003.Name)array spec (
fparser.two.Fortran2003.Array_Spec)char length (
fparser.two.Fortran2003.Char_Length)
- visit_Proc_Component_Def_Stmt(o, **kwargs)
 Procedure declaration statement
fparser.two.Fortran2003.Procedure_Declaration_Stmthas 3 children:fparser.two.Fortran2003.Name: the name of the procedure interfacefparser.two.Fortran2003.Proc_Attr_Spec_Listor None: the declared attributes (if any)fparser.two.Fortran2003.Proc_Decl_List: the local procedure names
- visit_Proc_Component_Attr_Spec_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Proc_Component_Attr_Spec(o, **kwargs)
 A declaration attribute
fparser.two.Fortran2003.Attr_Spechas no children.
- visit_Type_Bound_Procedure_Part(o, **kwargs)
 Procedure definitions part in a derived type definition
fparser.two.Fortran2003.Type_Bound_Procedure_Partstarts with the contains-stmt (fparser.two.Fortran2003.Contains_Stmt) followed by (optionally)fparser.two.Fortran2003.Binding_Private_Stmtand a sequence offparser.two.Fortran2003.Proc_Binding_Stmt
- visit_Specific_Binding(o, **kwargs)
 A specific binding for a type-bound procedure in a derived type
fparser.two.Fortran2003.Specific_Bindinghas five children:interface name
fparser.two.Fortran2003.Interface_Namebinding attr list
fparser.two.Fortran2003.Binding_Attr_List‘::’ (str) or None
name
fparser.two.Fortran2003.Binding_Nameprocedure name
fparser.two.Fortran2003.Procedure_Name
- visit_Generic_Binding(o, **kwargs)
 A generic binding for a type-bound procedure in a derived type
fparser.two.Fortran2003.Generic_Bindinghas three children:fparser.two.Fortran2003.Access_Specor None (access specifier)fparser.two.Fortran2003.Generic_Spec(the local name of the binding)fparser.two.Fortran2003.Binding_Name_List(the names it binds to)
- visit_Final_Binding(o, **kwargs)
 A final binding for type-bound procedures in a derived type
fparser.two.Fortran2003.Final_Bindinghas two children:keyword
'FINAL'(str)fparser.two.Fortran2003.Final_Subroutine_Name_List(the list of routines)
- visit_Binding_Name_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Final_Subroutine_Name_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Contains_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Binding_Private_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Private_Components_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Sequence_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Associate_Construct(o, **kwargs)
 The entire ASSOCIATE construct
fparser.two.Fortran2003.Associate_Constructhas a variable number of children:Any preceeding comments
fparser.two.Fortran2003.Commentfparser.two.Fortran2003.Associate_Stmt(the actual statement with the definition of associates)the body of the ASSOCIATE construct
- visit_Associate_Stmt(o, **kwargs)
 The ASSOCIATE statement with the association list
fparser.two.Fortran2003.Associate_Stmthas two children:The command ASSOCIATE (str)
The
fparser.two.Fortran2003.Association_Listdefining the associations
- visit_Association_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Association(o, **kwargs)
 A single association in an associate-stmt
fparser.two.Fortran2003.Associatehas two children:fparser.two.Fortran2003.Name(the new assigned name)the operator
=>(str)fparser.two.Fortran2003.Name(the associated expression)
- visit_Interface_Block(o, **kwargs)
 An
INTERFACEblockfparser.two.Fortran2003.Interface_Blockhas variable number of children:Any preceeding comments
fparser.two.Fortran2003.Commentfparser.two.Fortran2003.Interface_Stmt(the actual statement that begins the construct)the body, made up of
fparser.two.Fortran2003.Subroutine_Body,fparser.two.Fortran2003.Function_Body,fparser.two.Fortran2003.Procedure_Stmtand, potentially, any interleaving commentsfparser.two.Fortran2003.Commentthe closing
fparser.two.Fortran2003.End_Interface_Stmt
- visit_Interface_Stmt(o, **kwargs)
 The specification of the interface
fparser.two.Fortran2003.Interface_Stmthas one child, which is either:None, if no further specification exists
'ABSTRACT'(str) for an abstract interfacefparser.two.Fortran2003.Generic_Specfor other specifications
- visit_Generic_Spec(o, **kwargs)
 The generic-spec of an interface
fparser.two.Fortran2003.Generic_Spechas two children, which is either:'OPERATOR'(str) followed by
-or-
'ASSIGNMENT'(str) followed by'='(str)
- visit_Procedure_Stmt(o, **kwargs)
 Procedure statement
fparser.two.Fortran2003.Procedure_Stmthas 1 child:fparser.two.Fortran2003.Procedure_Name_List: the names of the procedures
- visit_Procedure_Name_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Procedure_Name(o, **kwargs)
 A symbol name
fparser.two.Fortran2003.Namehas no children.
- visit_Import_Stmt(o, **kwargs)
 An import statement for named entities in an interface body
fparser.two.Fortran2003.Import_Stmthas two children:The string
'IMPORT'fparser.two.Fortran2003.Import_Name_Listwith the names of imported entities
- visit_Import_Name_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Import_Name(o, **kwargs)
 A symbol name
fparser.two.Fortran2003.Namehas no children.
- visit_Main_Program(o, **kwargs)
 The entire block that comprises a
PROGRAMdefinitionLoki does currently not have support for
PROGRAMblocks, and this will raise aNotImplementedError
- visit_Subroutine_Subprogram(o, **kwargs)
 The entire block that comprises a
SUBROUTINEdefinition, i.e. everything from the subroutine-stmt to the end-stmtfparser.two.Fortran2003.Subroutine_Subprogramhas variable number of children, where the internal nodes may be optional:fparser.two.Fortran2003.Subroutine_Stmt(the opening statement)fparser.two.Fortran2003.Specification_Part(variable declarations, module imports etc.); due to an fparser bug, this can appear multiple times interleaved with the execution-partfparser.two.Fortran2003.Execution_Part(the body of the routine)fparser.two.Fortran2003.Internal_Subprogram_Part(any member procedures declared inside the procedure)fparser.two.Fortran2003.End_Subroutine_Stmt(the final statement)
- visit_Function_Subprogram(o, **kwargs)
 The entire block that comprises a
SUBROUTINEdefinition, i.e. everything from the subroutine-stmt to the end-stmtfparser.two.Fortran2003.Subroutine_Subprogramhas variable number of children, where the internal nodes may be optional:fparser.two.Fortran2003.Subroutine_Stmt(the opening statement)fparser.two.Fortran2003.Specification_Part(variable declarations, module imports etc.); due to an fparser bug, this can appear multiple times interleaved with the execution-partfparser.two.Fortran2003.Execution_Part(the body of the routine)fparser.two.Fortran2003.Internal_Subprogram_Part(any member procedures declared inside the procedure)fparser.two.Fortran2003.End_Subroutine_Stmt(the final statement)
- visit_Subroutine_Body(o, **kwargs)
 The entire block that comprises a
SUBROUTINEdefinition, i.e. everything from the subroutine-stmt to the end-stmtfparser.two.Fortran2003.Subroutine_Subprogramhas variable number of children, where the internal nodes may be optional:fparser.two.Fortran2003.Subroutine_Stmt(the opening statement)fparser.two.Fortran2003.Specification_Part(variable declarations, module imports etc.); due to an fparser bug, this can appear multiple times interleaved with the execution-partfparser.two.Fortran2003.Execution_Part(the body of the routine)fparser.two.Fortran2003.Internal_Subprogram_Part(any member procedures declared inside the procedure)fparser.two.Fortran2003.End_Subroutine_Stmt(the final statement)
- visit_Function_Body(o, **kwargs)
 The entire block that comprises a
SUBROUTINEdefinition, i.e. everything from the subroutine-stmt to the end-stmtfparser.two.Fortran2003.Subroutine_Subprogramhas variable number of children, where the internal nodes may be optional:fparser.two.Fortran2003.Subroutine_Stmt(the opening statement)fparser.two.Fortran2003.Specification_Part(variable declarations, module imports etc.); due to an fparser bug, this can appear multiple times interleaved with the execution-partfparser.two.Fortran2003.Execution_Part(the body of the routine)fparser.two.Fortran2003.Internal_Subprogram_Part(any member procedures declared inside the procedure)fparser.two.Fortran2003.End_Subroutine_Stmt(the final statement)
- visit_Subroutine_Stmt(o, **kwargs)
 The
SUBROUTINEstatementfparser.two.Fortran2003.Subroutine_Stmthas four children:name
fparser.two.Fortran2003.Subroutine_Namedummy argument list
fparser.two.Fortran2003.Dummy_Arg_Listsuffix
fparser.two.Fortran2003.Suffixor language binding specfparser.two.Fortran2003.Proc_Language_Binding_Spec
- visit_Function_Stmt(o, **kwargs)
 The
SUBROUTINEstatementfparser.two.Fortran2003.Subroutine_Stmthas four children:name
fparser.two.Fortran2003.Subroutine_Namedummy argument list
fparser.two.Fortran2003.Dummy_Arg_Listsuffix
fparser.two.Fortran2003.Suffixor language binding specfparser.two.Fortran2003.Proc_Language_Binding_Spec
- visit_Subroutine_Name(o, **kwargs)
 A symbol name
fparser.two.Fortran2003.Namehas no children.
- visit_Function_Name(o, **kwargs)
 A symbol name
fparser.two.Fortran2003.Namehas no children.
- visit_Dummy_Arg_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Prefix(o, **kwargs)
 The prefix of a subprogram definition
fparser.two.Fortran2003.Prefixhas variable number of children that have the typefparser.two.Fortran2003.Prefix_Specto declare attributesfparser.two.Fortran2003.Declaration_Type_Spec(or any of its variations) to declare the return type of a function
- visit_Prefix_Spec(o, **kwargs)
 A prefix keyword in a subprogram definition
fparser.two.Fortran2003.Prefix_Spechas no children
- visit_Suffix(o, **kwargs)
 The suffix of a subprogram statement
fparser.two.Fortran2003.Suffixhas two children:A
fparser.two.Fortran2003.Result_Nameif specified, or Nonea
fparser.two.Fortran2003.Language_Binding_Specif specified, or None
- visit_Language_Binding_Spec(o, **kwargs)
 A language binding spec suffix
fparser.two.Fortran2003.Language_Binding_Spechas a single child:fparser.two.Fortran2003.Char_Literal_Constantwith the name of the C routine it binds to
- visit_Module(o, **kwargs)
 The definition of a Fortran module
fparser.two.Fortran2003.Modulehas up to four children:The opening
fparser.two.Fortran2003.Module_StmtThe specification part
fparser.two.Fortran2003.Specification_PartThe module subprogram part
fparser.two.Fortran2003.Module_Subprogram_Partthe closing
fparser.two.Fortran2003.End_Module_Stmt
- visit_Module_Stmt(o, **kwargs)
 The
MODULEstatementfparser.two.Fortran2003.Module_Stmthas 2 children:keyword MODULE (str)
name
fparser.two.Fortran2003.Module_Name
- visit_Module_Name(o, **kwargs)
 A symbol name
fparser.two.Fortran2003.Namehas no children.
- visit_If_Construct(o, **kwargs)
 The entire
IFconstructfparser.two.Fortran2003.If_Constructhas variable number of children:Any preceeding comments
fparser.two.Fortran2003.Commentfparser.two.Fortran2003.If_Then_Stmt(the actual statement that begins the construct with the first condition)the body of the conditional branch
Optionally, one or more
fparser.two.Fortran2003.Else_If_Stmtfollowed by their corresponding bodiesOptionally, a
fparser.two.Fortran2003.Else_Stmtfollowed by its body
- visit_If_Then_Stmt(o, **kwargs)
 The first conditional in a
IFconstructfparser.two.Fortran2003.If_Then_Stmthas one child: the condition expression
- visit_Else_If_Stmt(o, **kwargs)
 The first conditional in a
IFconstructfparser.two.Fortran2003.If_Then_Stmthas one child: the condition expression
- visit_If_Stmt(o, **kwargs)
 An inline
IFstatement with a single statement as bodyfparser.two.Fortran2003.If_Stmthas two children:the condition expression
the body
- visit_Case_Construct(o, **kwargs)
 The entire
SELECT CASEconstructfparser.two.Fortran2003.Case_Constructhas variable number of children:Any preceeding comments
fparser.two.Fortran2003.Commentfparser.two.Fortran2003.Select_Case_Stmt(the actual statement with the selection expression)the body of the case-construct, containing one or multiple
fparser.two.Fortran2003.Case_Stmtfollowed by their corresponding bodies
- visit_Select_Case_Stmt(o, **kwargs)
 A
SELECT CASEstatement for a case-constructfparser.two.Fortran2003.Select_Case_Stmthas only one child: the selection expression.
- visit_Case_Stmt(o, **kwargs)
 A
CASEstatement in a case-constructfparser.two.Fortran2003.Case_Stmthas two children:the selection expression
fparser.two.Fortran2003.Case_Selector.the construct name
fparser.two.Fortran2003.Case_Construct_Nameor None
- visit_Case_Selector(o, **kwargs)
 The selector in a
CASEstatementfparser.two.Fortran2003.Case_Selectorhas one child: the value-range-listfparser.two.Fortran2003.Case_Value_Range_Listor None for theDEFAULTcase.
- visit_Case_Value_Range(o, **kwargs)
 The range of values in a
CASEstatementfparser.two.Fortran2003.Case_Value_Rangehas two children:start
fparser.two.Fortran2003.Case_Valueor Nonestop
fparser.two.Fortran2003.Case_Valueor None
- visit_Case_Value_Range_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Allocate_Stmt(o, **kwargs)
 A call to
ALLOCATEfparser.two.Fortran2003.Allocate_Stmthas three children:fparser.two.Fortran2003.Allocation_Listfparser.two.Fortran2003.Alloc_Opt_Listor None
- visit_Allocation_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Allocation(o, **kwargs)
 An allocation specification in an allocate-stmt
fparser.two.Fortran2003.Allocationhas two children:the name of the data object to be allocated:
fparser.two.Fortran2003.Allocate_Objectthe shape of the object:
fparser.two.Fortran2003.Allocate_Shape_Spec_List
- visit_Allocate_Shape_Spec(o, **kwargs)
 Explicit shape specification for arrays
fparser.two.Fortran2003.Explicit_Shape_Spechas 2 children:lower bound (if explicitly given)
upper bound
- visit_Allocate_Shape_Spec_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Alloc_Opt_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Dealloc_Opt_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Allocate_Object_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Alloc_Opt(o, **kwargs)
 An allocation option in an allocate-stmt
fparser.two.Fortran2003.Alloc_Opthas two children:the keyword (str)
the option value
- visit_Deallocate_Stmt(o, **kwargs)
 A call to
DEALLOCATEfparser.two.Fortran2003.Deallocate_Stmthas two children:the list of objects
fparser.two.Fortran2003.Allocate_Object_Listlist of options
fparser.two.Fortran2003.Dealloc_Opt_list
- visit_Dealloc_Opt(o, **kwargs)
 A deallocation option in a deallocate-stmt
fparser.two.Fortran2003.Dealloc_Opthas two children:the keyword (str)
the option value
- visit_Call_Stmt(o, **kwargs)
 A
CALLstatementfparser.two.Fortran2003.Call_Stmthas two children:the subroutine name
fparser.two.Fortran2003.Procedure_Designatorthe argument list
fparser.two.Fortran2003.Actual_Arg_Spec_List
- visit_Procedure_Designator(o, **kwargs)
 The function or subroutine designator
This appears only when a type-bound procedure is called (as otherwise Fparser hands through the relevant names directly).
fparser.two.Fortran2003.Procedure_Designatorhas three children:Parent name
fparser.two.Fortran2003.Data_Ref‘%’ (str)
procedure name
fparser.two.Fortran2003.Binding_Name
- visit_Actual_Arg_Spec_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Actual_Arg_Spec(o, **kwargs)
 A single argument in a subroutine call
fparser.two.Fortran2003.Actual_Arg_Spechas two children:keyword
fparser.two.Fortran2003.Keywordargument
fparser.two.Fortran2003.Actual_Arg
- visit_Function_Reference(o, **kwargs)
 An inline function call
fparser.two.Fortran2003.Actual_Arg_Spechas two children:the function name :class:fparser.two.Fortran2003.ProcedureDesignator`
the argument list
fparser.two.Fortran2003.Actual_Arg_Spec_List
- visit_Intrinsic_Function_Reference(o, **kwargs)
 
- visit_Intrinsic_Name(o, **kwargs)
 A symbol name
fparser.two.Fortran2003.Namehas no children.
- visit_Structure_Constructor(o, **kwargs)
 Call to the constructor of a derived type
fparser.two.Fortran2003.Structure_Constructorhas two children:the structure name
fparser.two.Fortran2003.Derived_Type_Specthe argument list
fparser.two.Fortran2003.Component_Spec_List
- visit_Component_Spec(o, **kwargs)
 A single argument in a subroutine call
fparser.two.Fortran2003.Actual_Arg_Spechas two children:keyword
fparser.two.Fortran2003.Keywordargument
fparser.two.Fortran2003.Actual_Arg
- visit_Component_Spec_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Enum_Def(o, **kwargs)
 The definition of an
ENUMfparser.two.Fortran2003.Enum_Defhas variable number of children:Any preceeding comments
fparser.two.Fortran2003.Commentfparser.two.Fortran2003.Enum_Def_Stmt(the statement indicating the beginning of the enum)the body of the enum, containing one or multiple
fparser.two.Fortran2003.Enumerator_Def_Stmt
- visit_Enumerator_Def_Stmt(o, **kwargs)
 A definition inside an
ENUMfparser.two.Fortran2003.Enumerator_Def_Stmthas 2 children:'ENUMERATOR'(str)fparser.two.Fortran2003.Enumerator_List(the constants)
- visit_Enumerator_List(o, **kwargs)
 Universal routine for auto-generated
*_Listtypes in fparser*_Listtypes have their items children
- visit_Enumerator(o, **kwargs)
 A constant definition within an
ENUM’s definition stmtfparser.two.Fortran2003.Enumeratorhas 3 children:fparser.two.Fortran2003.Name(the constant’s name)'='(str)the constant’s value given as some constant expression that must evaluate to an integer
- visit_Forall_Stmt(o, **kwargs)
 - Visit and process a single-line FORALL statement:
 FORALL (<variable> = <bound>[, <variable> = <bound>] … [, <mask>]) assign-stmt
- visit_Forall_Construct(o, **kwargs)
 - Visit and process a multi-line FORALL construct:
 - [name:] FORALL (<variable> = <bound>[, <variable> = <bound>] … [, <mask>])
 …body…
END FORALL [name]
Notes
Optional name of the construct is stored by fparser only in the End_Forall_Stmt at the end, and not in the beginning of the whole statement.
The body can consist of not only assignment statements, but also comments and nested FORALLs
- visit_Forall_Header(o, **kwargs)
 Visit FORALL header consisting of variables with their bounds and an optional mask
- visit_Forall_Triplet_Spec(o, **kwargs)
 Visit a triplet specification consisting of named variable, =, and a range (hence, the triplet!)
- visit_Where_Construct(o, **kwargs)
 Fortran’s masked array assignment construct
fparser.two.Fortran2003.Where_Constructhas variable number of children:Any preceeding comments
fparser.two.Fortran2003.Commentfparser.two.Fortran2003.Where_Construct_Stmt(the statement that marks the beginning of the construct)body of the where-construct, usually an assignment
(optional)
fparser.two.Fortran2003.Masked_Elsewhere_Stmt(essentially an “else-if”), followed by its body; this can appear more than once(optional)
fparser.two.Fortran2003.Elsewhere_Stmt(essentially an “else”), followed by its body
- visit_Where_Construct_Stmt(o, **kwargs)
 The
WHEREstatement that marks the beginning of a where-constructfparser.two.Fortran2003.Where_Construct_Stmthas 1 child:the expression that marks the condition
- visit_Masked_Elsewhere_Stmt(o, **kwargs)
 An
ELSEWHEREstatement with a condition in a where-constructfparser.two.Fortran2003.Masked_Elsewhere_Stmthas 2 children:the expression that marks the condition
the construct name or None
- visit_Elsewhere_Stmt(o, **kwargs)
 An unconditional
ELSEWHEREstatementfparser.two.Fortran2003.Elsewhere_Stmthas 2 children:'ELSEWHERE'(str)the construct name or None
- visit_Where_Stmt(o, **kwargs)
 An inline
WHEREassignmentfparser.two.Fortran2003.Where_Stmthas 2 children:the expression that marks the condition
the assignment
- visit_Base(o, **kwargs)
 Universal default for
BaseFParser-AST nodes
- visit_BlockBase(o, **kwargs)
 Universal default for
BlockBaseFParser-AST nodes
- visit_literal(o, _type, kind=None, **kwargs)
 
- visit_Char_Literal_Constant(o, **kwargs)
 
- visit_Int_Literal_Constant(o, **kwargs)
 
- visit_Signed_Int_Literal_Constant(o, **kwargs)
 
- visit_Real_Literal_Constant(o, **kwargs)
 
- visit_Signed_Real_Literal_Constant(o, **kwargs)
 
- visit_Logical_Literal_Constant(o, **kwargs)
 
- visit_Complex_Literal_Constant(o, **kwargs)
 
- visit_Binary_Constant(o, **kwargs)
 
- visit_Octal_Constant(o, **kwargs)
 
- visit_Hex_Constant(o, **kwargs)
 
- visit_Include_Stmt(o, **kwargs)
 
- visit_Implicit_Stmt(o, **kwargs)
 
- visit_Print_Stmt(o, **kwargs)
 
- visit_Comment(o, **kwargs)
 
- visit_Data_Pointer_Object(o, **kwargs)
 
- visit_Proc_Component_Ref(o, **kwargs)
 This is the compound object for accessing procedure components of a variable.
- visit_Block_Nonlabel_Do_Construct(o, **kwargs)
 
- visit_Block_Label_Do_Construct(o, **kwargs)
 
- visit_Nonlabel_Do_Stmt(o, **kwargs)
 
- visit_Label_Do_Stmt(o, **kwargs)
 
- visit_Loop_Control(o, **kwargs)
 
- visit_Assignment_Stmt(o, **kwargs)
 
- visit_Pointer_Assignment_Stmt(o, **kwargs)
 
- create_operation(op, exprs)
 Construct expressions from individual operations.
- visit_Add_Operand(o, **kwargs)
 
- visit_Mult_Operand(o, **kwargs)
 
- visit_And_Operand(o, **kwargs)
 
- visit_Or_Operand(o, **kwargs)
 
- visit_Equiv_Operand(o, **kwargs)
 
- visit_Level_2_Expr(o, **kwargs)
 
- visit_Level_2_Unary_Expr(o, **kwargs)
 
- visit_Level_3_Expr(o, **kwargs)
 
- visit_Level_4_Expr(o, **kwargs)
 
- visit_Level_5_Expr(o, **kwargs)
 
- visit_Parenthesis(o, **kwargs)
 
- visit_Format_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Write_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Goto_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Return_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Continue_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Cycle_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Exit_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Save_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Read_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Open_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Close_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Inquire_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Namelist_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Parameter_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Dimension_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Equivalence_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Common_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Stop_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Error_Stop_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Backspace_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Rewind_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Entry_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Cray_Pointer_Stmt(o, **kwargs)
 Universal routine to capture nodes as plain string in the IR
- visit_Cpp_If_Stmt(o, **kwargs)
 
- visit_Cpp_Elif_Stmt(o, **kwargs)
 
- visit_Cpp_Else_Stmt(o, **kwargs)
 
- visit_Cpp_Endif_Stmt(o, **kwargs)
 
- visit_Cpp_Macro_Stmt(o, **kwargs)
 
- visit_Cpp_Undef_Stmt(o, **kwargs)
 
- visit_Cpp_Line_Stmt(o, **kwargs)
 
- visit_Cpp_Warning_Stmt(o, **kwargs)
 
- visit_Cpp_Error_Stmt(o, **kwargs)
 
- visit_Cpp_Null_Stmt(o, **kwargs)
 
- visit_Cpp_Include_Stmt(o, **kwargs)
 
- visit_Select_Type_Construct(o, **kwargs)
 
- visit_Nullify_Stmt(o, **kwargs)
 
- parse_fparser_file(filename)
 Generate a parse tree from file via fparser
- parse_fparser_source(source)
 Generate a parse tree from string
- parse_fparser_ast(ast, raw_source, pp_info=None, definitions=None, scope=None)
 Generate an internal IR from fparser parse tree
- Parameters:
 ast – The fparser parse tree as created by
parse_fparser_sourceorparse_fparser_fileraw_source (str) – The raw source string from which
astwas generatedpp_info (optional) – Information from internal preprocessing step that was applied to work around parser limitations and that should be re-inserted
definitions (list of
Module, optional) – List of external module definitions to attach upon usescope (
Scope) – Scope object for which to parse the AST.
- Returns:
 The control flow tree
- Return type:
 
- parse_fparser_expression(source, scope)
 Parse an expression string into an expression tree.
This exploits Fparser’s internal parser structure that relies on recursively matching strings against a list of node types. Usually, this would start by matching against module, subroutine or program. Here, we shortcut this hierarchy by directly matching against a primary expression, thus this should be able to parse any syntactically correct Fortran expression.
- Parameters:
 - Returns:
 The expression tree corresponding to the expression
- Return type:
 
- get_fparser_node(ast, node_type_name, first_only=True, recurse=False)
 Extract child nodes with type given by
node_type_namefrom an fparser parse tree- Parameters:
 ast – The fparser parse tree as created by
parse_fparser_sourceorparse_fparser_filenode_type_name (str or list of str) – The name of the node type to extract, e.g. Module, Specification_Part etc.
first_only (bool, optional) – Return only first instance matching
node_type_name. Defaults to True.recurse (bool, optional) – Walk the entire parse tree instead of looking only in the children of
ast. Defaults to False.
- Returns:
 The node of requested type (or a list of these nodes if
allis True)- Return type:
 fparser.two.util.Base