Toggle main menu visibility
Loading...
Searching...
No Matches
constants.f90
Go to the documentation of this file.
1
!> @file
2
!! @defgroup group_constants Constants
3
!! Compile-time constants used throughout the fpx preprocessor.
4
!!
5
!! This module centralizes all numerical limits and fixed configuration
6
!! values required by the implementation. These parameters define the
7
!! maximum sizes of internal buffers and the allowed nesting depth of
8
!! various preprocessing constructs.
9
!!
10
!! The chosen values aim to balance flexibility and robustness:
11
!!
12
!! - large enough to accommodate realistic scientific Fortran code,
13
!! - small enough to avoid excessive memory consumption,
14
!! - fixed at compile time to simplify implementation and improve performance.
15
!!
16
!! The constants are used across multiple modules, including macro
17
!! expansion, conditional compilation, tokenization, and the extended
18
!! #for directive implementation.
19
!!
20
!! @section constants_examples Examples
21
!!
22
!! -# Limiting nested conditional directives:
23
!! @code{.f90}
24
!! #if A
25
!! #if B
26
!! #if C
27
!! !some code
28
!! #endif
29
!! #endif
30
!! #endif
31
!! ...
32
!! @endcode
33
!!
34
!! Nesting is permitted up to @link fpx_constants::max_cond_depth MAX_COND_DEPTH @endlink levels.
35
!!
36
!! -# Nested #for loops:
37
!! @code{.f90}
38
!! #for T in [integer, real]
39
!! #for K in [32, 64]
40
!! !some code
41
!! #endfor
42
!! #endfor
43
!! ...
44
!! @endcode
45
!!
46
!! Loop nesting is limited by @link fpx_constants::max_for_depth MAX_FOR_DEPTH @endlink.
47
!!
48
!! -# Long macro expansions:
49
!! @code{.f90}
50
!! #define MESSAGE "very long text ..."
51
!! ...
52
!! @endcode
53
!!
54
!! Intermediate buffers are sized according to @link fpx_constants::max_line_len MAX_LINE_LEN @endlink.
55
module
fpx_constants
56
implicit none
;
private
57
58
!> Maximum permitted length of an input or generated line.
59
!!
60
!! This limit applies to raw source lines, continued lines,
61
!! and intermediate results produced during macro expansion.
62
!!
63
!! The value should be sufficiently large for practically all
64
!! modern Fortran source files while preventing unbounded memory use.
65
!!
66
!! @ingroup group_constants
67
integer
,
parameter
,
public
::
max_line_len
= 4096
68
69
!> Maximum nesting depth of generic parser structures.
70
!!
71
!! Used internally whenever recursive parser constructs require
72
!! bounded stack-like storage.
73
!!
74
!! @ingroup group_constants
75
integer
,
parameter
,
public
::
max_depth
= 50
76
77
!> Maximum nesting depth of conditional compilation directives.
78
!!
79
!! Applies to constructs such as:
80
!! - `#if`
81
!! - `#ifdef`
82
!! - `#ifndef`
83
!! - `#elif`
84
!! - `#else`
85
!!
86
!! Excessive nesting beyond this limit results in diagnostics.
87
!!
88
!! @ingroup group_constants
89
integer
,
parameter
,
public
::
max_cond_depth
= 50
90
91
!> Maximum nesting depth of `#for` loops.
92
!!
93
!! Applies to the fpx extension:
94
!! @code
95
!! #for ...
96
!! !some code
97
!! #endfor
98
!! ...
99
!! @endcode
100
!!
101
!! Nested loops exceeding this limit generate an error.
102
!!
103
!! @ingroup group_constants
104
integer
,
parameter
,
public
::
max_for_depth
= 50
105
106
!> Maximum number of tokens generated during tokenization.
107
!!
108
!! This value bounds the temporary token buffers used by
109
!! expression parsing and macro processing.
110
!!
111
!! @ingroup group_constants
112
integer
,
parameter
,
public
::
max_tokens
= 100
113
114
!> Maximum number of parameters accepted by a macro definition.
115
!!
116
!! Applies to function-like macros:
117
!! @code
118
!! #define F(a,b,c) ...
119
!! ...
120
!! @endcode
121
!!
122
!! Variadic arguments count toward this limit.
123
!!
124
!! @ingroup group_constants
125
integer
,
parameter
,
public
::
max_params
= 10
126
127
!> Default chunk size used for internal buffering operations.
128
!!
129
!! This value is primarily used when processing data incrementally
130
!! to avoid frequent reallocations.
131
!!
132
!! @ingroup group_constants
133
integer
,
parameter
,
public
::
chksize
= 72
134
end module
fpx_constants::chksize
integer, parameter, public chksize
Default chunk size used for internal buffering operations.
Definition
constants.f90:133
fpx_constants::max_for_depth
integer, parameter, public max_for_depth
Maximum nesting depth of #for loops.
Definition
constants.f90:104
fpx_constants::max_depth
integer, parameter, public max_depth
Maximum nesting depth of generic parser structures.
Definition
constants.f90:75
fpx_constants::max_tokens
integer, parameter, public max_tokens
Maximum number of tokens generated during tokenization.
Definition
constants.f90:112
fpx_constants::max_params
integer, parameter, public max_params
Maximum number of parameters accepted by a macro definition.
Definition
constants.f90:125
fpx_constants::max_line_len
integer, parameter, public max_line_len
Maximum permitted length of an input or generated line.
Definition
constants.f90:67
fpx_constants::max_cond_depth
integer, parameter, public max_cond_depth
Maximum nesting depth of conditional compilation directives.
Definition
constants.f90:89
© 2026 davidpfister. All Rights Reserved.