loki.frontend.util
Functions
|
Cluster comments into comment blocks |
Combine multiline pragmas into single pragma nodes |
|
|
Identify inline comments and merge them onto statements |
|
Find labels and merge them onto the following node. |
|
Reads a file and returns the content as string. |
|
Utility function to sanitize internal representation after creating it from the parse tree of a frontend |
Classes
|
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:inline_comments
to attach inline-comments to IR nodescluster_comments
to combine multi-line comments intoCommentBlock
combine_multiline_pragmas
to combine multi-line pragmas into a single node
- Parameters:
_ir (
Node
) – The root node of the internal representation tree to be processedfrontend (
Frontend
) – The frontend from which the IR was createdpp_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