A module for parsing input files.
Oskar Weser, 2022
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private, | parameter | :: | max_line_length | = | 1028 | |
| character(len=*), | private, | parameter | :: | delimiter | = | ' ' | |
| character(len=*), | private, | parameter | :: | comment | = | '#' | |
| character(len=*), | private, | parameter | :: | alt_comment | = | '(' | |
| character(len=*), | private, | parameter | :: | concat | = | '\' | |
| character(len=*), | private, | parameter | :: | alt_concat | = | '+++' |
Construct a ManagingFileReader_t
If the argument echo_lines is present, then the read lines are
echoed to the unit echo_lines. If the argument is not present,
the echoing is switched off.
If err is not present, all errors will lead to a stop of the program.
Otherwise this argument contains the error code.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | file_name | |||
| integer, | intent(in), | optional | :: | echo_lines | ||
| integer, | intent(out), | optional | :: | err |
Construct an AttachedFileReader_t
If the argument echo_lines is present, then the read lines are
echoed to the unit echo_lines. If the argument is not present,
the echoing is switched off.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | file_id | |||
| integer, | intent(in), | optional | :: | echo_lines | ||
| character(len=*), | intent(in), | optional | :: | file_name | ||
| integer, | intent(in), | optional | :: | current_line |
An abstract class that supports tokenized reading of lines.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | file_id | ||||
| integer, | private, | allocatable | :: | echo_lines | |||
| character(len=:), | private, | allocatable | :: | file_name |
The file name of the open file (if available). |
||
| integer, | private, | allocatable | :: | current_line |
The current line (if available). The number refers to the line
just returned from |
| procedure , private , :: raw_nextline Function | |
| procedure , public :: close => my_close Subroutine | |
| procedure , public :: nextline Function | |
| procedure , public :: rewind => my_rewind Subroutine | |
| procedure , public :: set_echo_lines Subroutine | |
| procedure , public :: get_current_line Function | |
| procedure , public :: get_file_name Function |
A class for tokenized reading of lines, that manages the file access.
| public function construct_ManagingFileReader_t (file_name, echo_lines, err) | Construct a |
| procedure , public :: close => my_close Subroutine | |
| procedure , public :: nextline Function | |
| procedure , public :: rewind => my_rewind Subroutine | |
| procedure , public :: set_echo_lines Subroutine | |
| procedure , public :: get_current_line Function | |
| procedure , public :: get_file_name Function | |
| procedure , public :: is_open Function |
A class for tokenized reading of lines, that can be attached to open file handles.
| private function construct_AttachedFileReader_t (file_id, echo_lines, file_name, current_line) | Construct an |
| procedure , public :: close => my_close Subroutine | |
| procedure , public :: nextline Function | |
| procedure , public :: rewind => my_rewind Subroutine | |
| procedure , public :: set_echo_lines Subroutine | |
| procedure , public :: get_current_line Function | |
| procedure , public :: get_file_name Function |
A class for looping over tokens parsed from semantic lines.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(Token_t), | public, | allocatable | :: | tokens(:) | |||
| integer, | private | :: | i_curr_token | = | 1 | ||
| character(len=:), | private, | allocatable | :: | file_name |
The name of file where the line came from (if available). |
||
| integer, | private, | allocatable | :: | current_line |
The current line (if available). |
| procedure , public :: size => size_TokenIterator_t Function | |
| procedure , public :: remaining_items Function | |
| procedure , public :: next Function | |
| procedure , public :: glimpse Function | |
| procedure , public :: reset Subroutine |
Construct a ManagingFileReader_t
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | file_name | |||
| integer, | intent(in), | optional | :: | echo_lines | ||
| integer, | intent(out), | optional | :: | err |
Construct an AttachedFileReader_t
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | file_id | |||
| integer, | intent(in), | optional | :: | echo_lines | ||
| character(len=*), | intent(in), | optional | :: | file_name | ||
| integer, | intent(in), | optional | :: | current_line |
Return if a file is open.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ManagingFileReader_t), | intent(in) | :: | this |
Return if the next line can be read and return it
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(FileReader_t), | intent(inout) | :: | this | |||
| character(len=:), | intent(out), | allocatable | :: | line |
Return if the next line can be read. It is written to the out-argument.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(FileReader_t), | intent(inout) | :: | this | |||
| type(TokenIterator_t), | intent(out) | :: | tokenized_line | |||
| logical, | intent(in) | :: | skip_empty |
Tokenize a line.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | line |
Return the number of remaining items in this Iterator.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(TokenIterator_t), | intent(in) | :: | this |
Return the number of tokens in this Iterator.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(TokenIterator_t), | intent(in) | :: | this |
Return the next Token and increment the iterator.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(TokenIterator_t), | intent(inout) | :: | this | |||
| character(len=*), | intent(in), | optional | :: | if_exhausted |
Return the next Token.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(TokenIterator_t), | intent(inout) | :: | this | |||
| character(len=*), | intent(in), | optional | :: | if_exhausted |
Parse a string into a range of integers.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | str_range |
Return the file name (if defined)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(FileReader_t), | intent(in) | :: | this |
Return the current line (if defined)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(FileReader_t), | intent(in) | :: | this |
Close the file.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(FileReader_t), | intent(inout) | :: | this | |||
| logical, | intent(in), | optional | :: | delete |
Rewind the file
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(FileReader_t), | intent(inout) | :: | this |
Set the unit where to echo lines.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(FileReader_t), | intent(inout) | :: | this | |||
| integer, | intent(in), | optional | :: | echo_lines |
Reset the iterator
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(TokenIterator_t), | intent(inout) | :: | this | |||
| integer, | intent(in), | optional | :: | k |