Fortran Preprocessor (fpx) – core parsing and preprocessing module
This module implements a full-featured, modern Fortran preprocessor supporting:
\ and \\& continuations#define, #undef, object-like and function-like macros with variadic support#include with proper path resolution and recursion guard#if, #ifdef, #ifndef, #elif, #else, #endif/* ... */ comments (nestable aware)#) / token-pasting (##)The preprocessor is designed to be standards-conforming where possible while adding useful extensions (variadic macros, better diagnostics, include path handling).
Data Types | |
| interface | preprocess |
| Generic interface to start preprocessing from various sources/sinks. More... | |
|
private |
Preprocess a file and write result to an optional output file (default: stdout) Opens the input file, determines the base filename for error messages, opens the output file if requested, and delegates to the unit-to-unit routine.
| [in] | filepath | Path to the input source file |
| [in] | outputfile | Optional path to the output file; if absent output goes to stdout |
Remarks
Definition at line 111 of file parser.f90.
|
private |
Preprocess a file and write to an already-open output unit.
| [in] | ifile | Input filename |
| [in] | ounit | Output unit (already open for writing) |
Remarks
Definition at line 179 of file parser.f90.
|
private |
Worker routine that reads lines, handles continuations, comments and directives This is the main loop that:
\ and & continuations&) is active | [in] | iunit | Input unit |
| [in] | ounit | Output unit |
| [in,out] | macros(:) | Current macro table (passed by value between include levels) |
| [in] | from_include | True if called recursively from include |
Definition at line 256 of file parser.f90.
|
private |
Preprocess from an already-open input unit and write to a file.
| [in] | iunit | Input unit (must already be open for reading) |
| [in] | ofile | Output filename |
Remarks
Definition at line 151 of file parser.f90.
|
private |
Core preprocessing routine: read from iunit, write to ounit Sets up a clean macro environment for the top-level file, resets conditional compilation state, and calls the worker routine.
| [in] | iunit | Input unit |
| [in] | ounit | Output unit |
Remarks
Definition at line 210 of file parser.f90.
|
private |
Process a single (possibly continued) line – handles directives and macro expansion Responsibilities:
/* ... */)#define, #include, conditionals, etc.)& continuation inside macros) | [in] | current_line | Input line (already continued and trimmed) |
| [in] | ounit | Output unit (used only for diagnostics inside called routines) |
| [in] | filepath | Current file name (for error messages) |
| [in] | linenum | Current line number (for error messages) |
| [in,out] | macros(:) | Macro table |
| [out] | stch | Set to .true. if the expanded line ends with & (stitch next line) |
Definition at line 368 of file parser.f90.