fparser.common.base_classes

Base classes for all Fortran statement types

Module Contents

Classes

AttributeHolder

Defines a object with predefined attributes. Only those attributes

Variable

Variable instance has attributes:

ProgramBlock

Statement

Statement instance has attributes:

BeginStatement

EndStatement

END [<blocktype> [<name>]]

class fparser.common.base_classes.AttributeHolder(**kws)[source]

Defines a object with predefined attributes. Only those attributes are allowed that are specified as keyword arguments of a constructor. When an argument is callable then the corresponding attribute will be read-only and set by the value the callable object returns.

__getattr__(name)[source]
__setattr__(name, value)[source]

Implement setattr(self, name, value).

isempty()[source]
__repr__()[source]

Return repr(self).

torepr(depth=-1, tab='')[source]
todict()[source]
class fparser.common.base_classes.Variable(parent, name)[source]

Variable instance has attributes:

name
typedecl
dimension
attributes
intent
parent - Statement instances defining the variable
known_intent_specs = ['IN', 'OUT', 'INOUT', 'CACHE', 'HIDE', 'COPY', 'OVERWRITE', 'CALLBACK', 'AUX', 'C', 'INPLACE', 'OUT='][source]
known_attributes = ['PUBLIC', 'PRIVATE', 'ALLOCATABLE', 'ASYNCHRONOUS', 'EXTERNAL', 'INTRINSIC', 'OPTIONAL',...[source]
__repr__()[source]

Return repr(self).

get_typedecl()[source]
add_parent(parent)[source]
set_type(typedecl)[source]
set_init(expr)[source]
set_dimension(dims)[source]
set_bounds(bounds)[source]
set_length(length)[source]
set_intent(intent)[source]
is_intent_in()[source]
is_intent_inout()[source]
is_intent_hide()[source]
is_intent_inplace()[source]
is_intent_out()[source]
is_intent_c()[source]
is_intent_cache()[source]
is_intent_copy()[source]
is_intent_overwrite()[source]
is_intent_callback()[source]
is_intent_aux()[source]
is_private()[source]
is_public()[source]
is_allocatable()[source]
is_external()[source]
is_intrinsic()[source]
is_parameter()[source]
is_optional()[source]
is_required()[source]
is_pointer()[source]
is_array()[source]
is_scalar()[source]
update(*attrs)[source]
__str__()[source]

Return str(self).

get_array_spec()[source]
is_deferred_shape_array()[source]
is_assumed_size_array()[source]
is_assumed_shape_array()[source]
is_explicit_shape_array()[source]
is_allocatable_array()[source]
is_array_pointer()[source]
analyze()[source]
error(message)[source]
warning(message)[source]
info(message)[source]
class fparser.common.base_classes.ProgramBlock[source]
class fparser.common.base_classes.Statement(parent, item)[source]

Statement instance has attributes:

parent  - Parent BeginStatement or FortranParser instance
item    - Line instance containing the statement line
isvalid - boolean, when False, the Statement instance will be ignored
modes = ['free', 'fix', 'f77', 'pyf'][source]
_repr_attr_names = [][source]
__repr__()[source]

Return repr(self).

torepr(depth=-1, incrtab='')[source]
get_indent_tab(deindent=False, isfix=None)[source]
__str__()[source]

Return str(self).

asfix()[source]
format_message(kind, message)[source]
error(message)[source]
warning(message)[source]
info(message)[source]
analyze()[source]
get_variable(name)[source]

Return Variable instance of variable name.

get_type(name)[source]

Return type declaration using implicit rules for name.

get_type_decl(kind)[source]
get_provides()[source]

Returns dictonary containing statements that block provides or None when N/A.

class fparser.common.base_classes.BeginStatement(parent, item=None)[source]

Bases: Statement

[ construct_name : ] <blocktype> [ <name> ]

BeginStatement instances have additional attributes:

name
blocktype

Block instance has attributes:

content - list of Line or Statement instances
name    - name of the block, unnamed blocks are named
          with the line label
construct_name - name of a construct
parent  - Block or FortranParser instance
item    - Line instance containing the block start statement
get_item, put_item - methods to retrive/submit Line instances
          from/to Fortran reader.
isvalid - boolean, when False, the Block instance will be ignored.

stmt_cls, end_stmt_cls
_repr_attr_names[source]
tostr()[source]
tofortran(isfix=None)[source]
torepr(depth=-1, incrtab='')[source]
process_item()[source]

Process the line

fill(end_flag=False)[source]

Fills blocks content until the end of block statement.

process_subitem(item)[source]

Check if item is blocks start statement, if it is, read the block.

Return True to stop adding items to given block.

handle_unknown_item_and_raise(item)[source]

Called when process_subitem does not find a start or end of block. It adds the item (which is an instance of Line) to the content, but then raises an AnalyzeError. An instance of Line in content typically results in other errors later (e.g. because Line has no analyze method).

analyze()[source]
class fparser.common.base_classes.EndStatement(parent, item)[source]

Bases: Statement

END [<blocktype> [<name>]]

EndStatement instances have additional attributes:

name
blocktype
_repr_attr_names[source]
process_item()[source]
analyze()[source]
get_indent_tab(deindent=False, isfix=None)[source]
tofortran(isfix=None)[source]

Returns a valid Fortran string for this END statement. It guarantees that there is no white space after the ‘END’ in case of an unnamed statement.

Parameters:

isfix (bool) – True if the code is in fixed format.

Returns:

the (named or unnamed) valid Fortran END statement as a string.

Return type:

str