fparser.common.base_classes =========================== .. py:module:: fparser.common.base_classes .. autoapi-nested-parse:: Base classes for all Fortran statement types Classes ------- .. autoapisummary:: fparser.common.base_classes.AttributeHolder fparser.common.base_classes.Variable fparser.common.base_classes.ProgramBlock fparser.common.base_classes.Statement fparser.common.base_classes.BeginStatement fparser.common.base_classes.EndStatement Module Contents --------------- .. py:class:: AttributeHolder(**kws) 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. .. py:attribute:: _attributes .. py:attribute:: _readonly :value: [] .. py:method:: __getattr__(name) .. py:method:: __setattr__(name, value) .. py:method:: isempty() .. py:method:: __repr__() .. py:method:: torepr(depth=-1, tab='') .. py:method:: todict() .. py:class:: Variable(parent, name) Variable instance has attributes:: name typedecl dimension attributes intent parent - Statement instances defining the variable .. py:attribute:: parent .. py:attribute:: parents .. py:attribute:: name .. py:attribute:: typedecl :value: None .. py:attribute:: dimension :value: None .. py:attribute:: bounds :value: None .. py:attribute:: length :value: None .. py:attribute:: attributes :value: [] .. py:attribute:: intent :value: None .. py:attribute:: bind :value: [] .. py:attribute:: check :value: [] .. py:attribute:: init :value: None .. py:method:: __repr__() .. py:method:: get_typedecl() .. py:method:: add_parent(parent) .. py:method:: set_type(typedecl) .. py:method:: set_init(expr) .. py:method:: set_dimension(dims) .. py:method:: set_bounds(bounds) .. py:method:: set_length(length) .. py:attribute:: known_intent_specs :value: ['IN', 'OUT', 'INOUT', 'CACHE', 'HIDE', 'COPY', 'OVERWRITE', 'CALLBACK', 'AUX', 'C', 'INPLACE', 'OUT='] .. py:method:: set_intent(intent) .. py:attribute:: known_attributes :value: ['PUBLIC', 'PRIVATE', 'ALLOCATABLE', 'ASYNCHRONOUS', 'EXTERNAL', 'INTRINSIC', 'OPTIONAL',... .. py:method:: is_intent_in() .. py:method:: is_intent_inout() .. py:method:: is_intent_hide() .. py:method:: is_intent_inplace() .. py:method:: is_intent_out() .. py:method:: is_intent_c() .. py:method:: is_intent_cache() .. py:method:: is_intent_copy() .. py:method:: is_intent_overwrite() .. py:method:: is_intent_callback() .. py:method:: is_intent_aux() .. py:method:: is_private() .. py:method:: is_public() .. py:method:: is_allocatable() .. py:method:: is_external() .. py:method:: is_intrinsic() .. py:method:: is_parameter() .. py:method:: is_optional() .. py:method:: is_required() .. py:method:: is_pointer() .. py:method:: is_array() .. py:method:: is_scalar() .. py:method:: update(*attrs) .. py:method:: __str__() .. py:method:: get_array_spec() .. py:method:: is_deferred_shape_array() .. py:method:: is_assumed_size_array() .. py:method:: is_assumed_shape_array() .. py:method:: is_explicit_shape_array() .. py:method:: is_allocatable_array() .. py:method:: is_array_pointer() .. py:method:: analyze() .. py:method:: error(message) .. py:method:: warning(message) .. py:method:: info(message) .. py:class:: ProgramBlock .. py:class:: Statement(parent, item) 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 .. py:attribute:: modes :value: ['free', 'fix', 'f77', 'pyf'] .. py:attribute:: _repr_attr_names :value: [] .. py:attribute:: parent .. py:attribute:: top .. py:attribute:: item .. py:attribute:: isvalid :value: True .. py:attribute:: ignore :value: False .. py:attribute:: a .. py:method:: __repr__() .. py:method:: torepr(depth=-1, incrtab='') .. py:method:: get_indent_tab(deindent=False, isfix=None) .. py:method:: __str__() .. py:method:: asfix() .. py:method:: format_message(kind, message) .. py:method:: error(message) .. py:method:: warning(message) .. py:method:: info(message) .. py:method:: analyze() .. py:method:: get_variable(name) Return Variable instance of variable name. .. py:method:: get_type(name) Return type declaration using implicit rules for name. .. py:method:: get_type_decl(kind) .. py:method:: get_provides() Returns dictonary containing statements that block provides or None when N/A. .. py:class:: BeginStatement(parent, item=None) Bases: :py:obj:`Statement` :: [ construct_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 .. py:attribute:: _repr_attr_names :value: ['blocktype', 'name', 'construct_name'] .. py:attribute:: content :value: [] .. py:attribute:: get_item .. py:attribute:: put_item .. py:attribute:: construct_name :value: None .. py:method:: tostr() .. py:method:: tofortran(isfix=None) .. py:method:: torepr(depth=-1, incrtab='') .. py:method:: process_item() Process the line .. py:method:: fill(end_flag=False) Fills blocks content until the end of block statement. .. py:method:: process_subitem(item) Check if item is blocks start statement, if it is, read the block. Return True to stop adding items to given block. .. py:method:: handle_unknown_item_and_raise(item) 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). .. py:method:: analyze() .. py:class:: EndStatement(parent, item) Bases: :py:obj:`Statement` END [ []] EndStatement instances have additional attributes:: name blocktype .. py:attribute:: _repr_attr_names :value: ['blocktype', 'name'] .. py:method:: process_item() .. py:method:: analyze() .. py:method:: get_indent_tab(deindent=False, isfix=None) .. py:method:: tofortran(isfix=None) 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. :param bool isfix: True if the code is in fixed format. :returns: the (named or unnamed) valid Fortran END statement as a string. :rtype: str