loki.frontend.util

Functions

cluster_comments(ir)

Cluster comments into comment blocks

combine_multiline_pragmas(ir)

Combine multiline pragmas into single pragma nodes

inline_comments(ir)

Identify inline comments and merge them onto statements

inline_labels(ir)

Find labels and merge them onto the following node.

read_file(file_path)

Reads a file and returns the content as string.

sanitize_ir(_ir, frontend[, pp_registry, ...])

Utility function to sanitize internal representation after creating it from the parse tree of a frontend

Classes

Frontend(value[, names, module, qualname, ...])

Enumeration to identify available frontends.

class Frontend(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntEnum

Enumeration to identify available frontends.

OMNI = 1

The OMNI compiler frontend

OFP = 2

The Open Fortran Parser

FP = 3

Fparser 2 from STFC

REGEX = 4

Reduced functionality parsing using regular expressions

inline_comments(ir)

Identify inline comments and merge them onto statements

cluster_comments(ir)

Cluster comments into comment blocks

read_file(file_path)

Reads a file and returns the content as string.

This convenience function is provided to catch read errors due to bad character encodings in the file. It skips over these characters and prints a warning for the first occurence of such a character.

combine_multiline_pragmas(ir)

Combine multiline pragmas into single pragma nodes

sanitize_ir(_ir, frontend, pp_registry=None, pp_info=None)

Utility function to sanitize internal representation after creating it from the parse tree of a frontend

It carries out post-processing according to pp_info and applies the following operations:

Parameters:
  • _ir (Node) – The root node of the internal representation tree to be processed

  • frontend (Frontend) – The frontend from which the IR was created

  • pp_registry (dict, optional) – Registry of pre-processing items to be applied

  • pp_info (optional) – Information from internal preprocessing step that was applied to work around parser limitations and that should be re-inserted