Loading...
Searching...
No Matches
macro.f90 File Reference

Go to the source code of this file.

Data Types

type  macro
 Derived type representing a single preprocessor macro Extends string with macro-specific fields: replacement value, parameters, variadic flag, and cyclic self-reference detection. More...
 
interface  add
 Add one or more macros to a dynamic table. More...
 
interface  clear
 Remove all macros from a table. More...
 
interface  get
 Retrieve a macro by index. More...
 
interface  insert
 Insert more macro to a dynamic table. More...
 
interface  remove
 Remove a macro at given index. More...
 
interface  sizeof
 Return current number of stored macros. More...
 

Functions/Subroutines

type(macro) function macro_new (name, val)
 Construct a new macro object.
 
character(:) function, allocatable, public expand_all (line, macros, filepath, iline, stitch, has_extra)
 Fully expand a line including predefined macros (FILE, LINE, etc.) First performs normal macro expansion via expand_macros(), then substitutes standard predefined tokens with current file/line/date information.
 
character(:) function, allocatable, public expand_macros (line, macros, stitch)
 Core recursive macro expander (handles function-like, variadic, #, ##)
 
recursive character(:) function, allocatable expand_macros_internal (line, imacro, macros)
 
logical function is_circular (macros, idx)
 Detect whether expanding macro at index idx would cause a cycle Builds a dependency graph from macro replacement texts and checks for circular paths. Used during expansion to avoid infinite recursion.
 
logical function, public is_defined (name, macros, idx)
 Check if a macro with given name exists in table.
 
character(:) function, allocatable tostring (any)
 Generic conversion of polymorphic value to string Used internally during macro argument stringification and debugging. Supports integers, reals, logicals, characters, and complex.
 
subroutine print_any (any)
 
subroutine add_to (vec, val, n, chunk_size, finished)
 Internal helper: grow dynamic macro array in chunks for efficiency Adds a new macro to the allocatable array, growing in BUFFER_SIZE increments. Also detects direct self-references (A → A) and marks both sides as cyclic.
 
subroutine add_item (this, arg)
 Add a complete macro object to the table.
 
subroutine add_item_from_name (this, name)
 Add macro by name only (value = empty)
 
subroutine add_item_from_name_and_value (this, name, value)
 Add macro with name and replacement text.
 
subroutine add_range (this, args)
 Add multiple macros at once.
 
subroutine clear_item (this)
 Remove all macros from table.
 
type(macro) function, allocatable get_item (this, key)
 Retrieve macro by 1-based index.
 
subroutine insert_item (this, i, arg)
 Insert macro at specific position.
 
integer function size_item (this)
 Return number of defined macros.
 
subroutine remove_item (this, i)
 Remove macro at given index.
 

Variables

integer, parameter buffer_size = 256
 Default buffer size.