coan 4.2.4
|
![]() |
Modules | |
Macro-generated code | |
Files | |
file | if_control.c |
Defines | |
#define | MAXDEPTH 64 |
Typedefs | |
typedef void | transition_t (void) |
Functions | |
static void | done_file (void) |
static void | nest (void) |
static void | set_state (if_state_t is) |
static void | Strue (void) |
static void | Sfalse (void) |
static void | Selse (void) |
static void | Pelif (void) |
static void | Pelse (void) |
static void | Pendif (void) |
static void | Dfalse (void) |
static void | Delif (void) |
static void | Delse (void) |
static void | Dendif (void) |
static void | Fdrop (void) |
static void | Fpass (void) |
static void | Ftrue (void) |
static void | Ffalse (void) |
static void | Mpass (void) |
static void | Mtrue (void) |
static void | Melif (void) |
static void | Melse (void) |
Variables | |
static transition_t *const | transition_table [IF_STATE_COUNT][LT_SENTINEL] |
The component is essentially a state machine. The implementation differs only trivially from that of Tony Finch
A state transition function alters the global hash-if processing state in a particular way. The state table is indexed by the current processing state and the type of the current line.
Nesting is handled by keeping a stack of states; some transition functions increase or decrease the depth. In some complicated cases they have to alter the preprocessor directive, as follows:
When we have processed a group that starts off with a known false hash-if/#elif sequence (which has therefore been deleted) followed by an hash-elif that we cannot resolve and therefore must keep, we edit the latter into a #if to keep the nesting correct.
When we find a true hash-elif in a group, the following block will always be kept and the rest of the sequence after the next hash-elif or hash-else will be discarded. We edit the true hash-elif into an hash-else and the following directive to hash-endif since this has the desired behaviour.
"Dodgy" directives are split across multiple lines, the most common example being a multi-line comment hanging off the right of the directive. We can handle them correctly only if there is no change from printing to dropping (or vice versa) caused by that directive. If the directive is the first of a group we have a choice between failing with an error, or passing it through unchanged instead of evaluating it. The latter is not the default to avoid user questions about preprocessor directives being unexpectedly retained.
#define MAXDEPTH 64 |
Maximum depth of hash-if nesting, c.f. Minimum translation limits from ISO/IEC 9899:1999 5.2.4.1
Definition at line 62 of file if_control.c.
Referenced by nest().
typedef void transition_t(void) |
Type of if-state transition functions.
Definition at line 67 of file if_control.c.
static void Delif | ( | void | ) | [static] |
State transition
Definition at line 124 of file if_control.c.
References drop(), IF_STATE_FALSE_MIDDLE, and set_state().
static void Delse | ( | void | ) | [static] |
State transition
Definition at line 130 of file if_control.c.
References drop(), IF_STATE_FALSE_ELSE, and set_state().
static void Dendif | ( | void | ) | [static] |
State transition
Definition at line 392 of file if_control.c.
References drop(), and SET_STATE.
static void Dfalse | ( | void | ) | [static] |
State transition
Definition at line 118 of file if_control.c.
References drop(), IF_STATE_FALSE_TRAILER, and set_state().
Referenced by Fdrop().
static void done_file | ( | void | ) | [static] |
End-of-file routine. Trap errors for end of file within comment or within quotation. Reset nesting depth = 0
Definition at line 355 of file if_control.c.
References GET_PUBLIC, GRIPE_EOF_IN_COMMENT, GRIPE_EOF_IN_QUOTE, NO_COMMENT, and parse_error().
static void Fdrop | ( | void | ) | [static] |
State transition
Definition at line 138 of file if_control.c.
References Dfalse(), and nest().
static void Ffalse | ( | void | ) | [static] |
State transition
Definition at line 156 of file if_control.c.
References nest(), and Sfalse().
static void Fpass | ( | void | ) | [static] |
State transition
Definition at line 144 of file if_control.c.
References nest(), and Pelif().
static void Ftrue | ( | void | ) | [static] |
State transition
Definition at line 150 of file if_control.c.
References nest(), and Strue().
static void Melif | ( | void | ) | [static] |
State transition
Definition at line 174 of file if_control.c.
References IF_STATE_FALSE_TRAILER, keywordedit(), and set_state().
static void Melse | ( | void | ) | [static] |
State transition
Definition at line 180 of file if_control.c.
References IF_STATE_FALSE_ELSE, keywordedit(), and set_state().
static void Mpass | ( | void | ) | [static] |
State transition
Definition at line 162 of file if_control.c.
References GET_PUBLIC, and Pelif().
static void Mtrue | ( | void | ) | [static] |
State transition
Definition at line 168 of file if_control.c.
References IF_STATE_TRUE_MIDDLE, keywordedit(), and set_state().
static void nest | ( | void | ) | [static] |
Increment the nesting depth.
Definition at line 370 of file if_control.c.
References bail(), GET_PUBLIC, GET_STATE, GRIPE_TOO_DEEP, MAXDEPTH, and SET_STATE.
Referenced by Fdrop(), Ffalse(), Fpass(), and Ftrue().
static void Pelif | ( | void | ) | [static] |
State transition
Definition at line 104 of file if_control.c.
References IF_STATE_PASS_MIDDLE, print(), and set_state().
Referenced by Fpass(), and Mpass().
static void Pelse | ( | void | ) | [static] |
State transition
Definition at line 110 of file if_control.c.
References IF_STATE_PASS_ELSE, print(), and set_state().
static void Pendif | ( | void | ) | [static] |
State transition
Definition at line 386 of file if_control.c.
References print(), and SET_STATE.
static void Selse | ( | void | ) | [static] |
State transition
Definition at line 98 of file if_control.c.
References drop(), IF_STATE_TRUE_ELSE, and set_state().
static void set_state | ( | if_state_t | is | ) | [static] |
Assign the if-control state at the current nesting depth.
is | The state to be assigned. |
Definition at line 380 of file if_control.c.
References GET_STATE, and if_depth().
Referenced by Delif(), Delse(), Dfalse(), Melif(), Melse(), Mtrue(), Pelif(), Pelse(), Selse(), Sfalse(), and Strue().
static void Sfalse | ( | void | ) | [static] |
State transition
Definition at line 92 of file if_control.c.
References drop(), IF_STATE_FALSE_PREFIX, and set_state().
Referenced by Ffalse().
static void Strue | ( | void | ) | [static] |
State transition
Definition at line 86 of file if_control.c.
References drop(), IF_STATE_TRUE_PREFIX, and set_state().
Referenced by Ftrue().
transition_t* const transition_table[IF_STATE_COUNT][LT_SENTINEL] [static] |
The state transition table
An array of pointers to state transition functions.
Definition at line 191 of file if_control.c.
Referenced by transition().