fpm_source_parsing Module

Parsing of package source files

This module exposes two functions, [[parse_f_source]] and [[parse_c_source]], which perform a rudimentary parsing of fortran and c source files in order to extract information required for module dependency tracking.

Both functions additionally calculate and store a file digest (hash) which is used by the backend (fpm_backend) to skip compilation of unmodified sources.

Both functions return an instance of the srcfile_t type.

For more information, please read the documentation for each function:

  • [[parse_f_source]]
  • [[parse_c_source]]


Functions

public function parse_c_source(c_filename, error) result(c_source)

Parsing of c, cpp source files

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: c_filename
type(error_t), intent(out), allocatable :: error

Return Value type(srcfile_t)

public function parse_f_source(f_filename, error) result(f_source)

Parsing of free-form fortran source files

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: f_filename
type(error_t), intent(out), allocatable :: error

Return Value type(srcfile_t)


Subroutines

public subroutine parse_use_statement(f_filename, i, line, use_stmt, is_intrinsic, module_name, error)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: f_filename

Current file name and line number (for error messaging)

integer, intent(in) :: i
character(len=*), intent(in) :: line

The line being parsed. MUST BE preprocessed with trim(adjustl()

logical, intent(out) :: use_stmt

Does this line contain a use statement?

logical, intent(out) :: is_intrinsic

Is the module in this statement intrinsic?

character(len=:), intent(out), allocatable :: module_name

used module name

type(error_t), intent(out), allocatable :: error

Error handling