psyclone.psyir.frontend.fortran
This module provides the PSyIR Fortran front-end.
Classes
FortranReader
: PSyIR Fortran frontend. This frontend translates Fortran from a string
- class psyclone.psyir.frontend.fortran.FortranReader
PSyIR Fortran frontend. This frontend translates Fortran from a string or a file into PSyIR using the fparser2 utilities.
Inheritance
- psyir_from_expression(source_code: str, symbol_table: SymbolTable | None = None)
Generate the PSyIR tree for the supplied Fortran statement. The symbol table is expected to provide all symbols found in the expression.
- Parameters:
source_code – text of the expression to be parsed.
symbol_table – the SymbolTable in which to search for any symbols that are encountered.
- Returns:
PSyIR representing the provided Fortran expression.
- Return type:
- Raises:
TypeError – if no valid SymbolTable is supplied.
ValueError – if the supplied source does not represent a Fortran expression.
- psyir_from_file(file_path, free_form=True)
Generate the PSyIR tree representing the given Fortran file.
- Parameters:
file_path (str or any Python Path format.) – path of the file to be read and parsed.
free_form (bool) – If parsing free-form code or not (default True).
- Returns:
PSyIR representing the provided Fortran file.
- Return type:
- psyir_from_source(source_code: str, free_form: bool = True)
Generate the PSyIR tree representing the given Fortran source code.
- Parameters:
source_code – text representation of the code to be parsed.
free_form – If parsing free-form code or not (default True).
- Returns:
PSyIR representing the provided Fortran source code.
- Return type:
- psyir_from_statement(source_code: str, symbol_table: SymbolTable | None = None)
Generate the PSyIR tree for the supplied Fortran statement. The symbolt table is expected to provide all symbols found in the statement.
- Parameters:
source_code – text of the statement to be parsed.
symbol_table – the SymbolTable in which to search for any symbols that are encountered.
- Returns:
PSyIR representing the provided Fortran statement.
- Return type:
- Raises:
TypeError – if no valid SymbolTable is supplied.
ValueError – if the supplied source does not represent a Fortran statement.
- static validate_name(name: str)
Utility method that checks that the supplied name is a valid Fortran name.
- Parameters:
name – the name to check.
- Raises:
TypeError – if the name is not a string.
ValueError – if this is not a valid name.