static void lex_error(yyscan_t yyscanner, char const *const message, ...)

Emit an error message, increment error counter.

static global_state *init_global_state(char *const filename, FILE *outfile)

Create and initialize a global_state structure, containing all 'global' variables that are needed during the scanning.

static void destroy_global_state(global_state *state)

Free all memory of the global state structure.

void process_heredocs(char *const filename, FILE *outputfile)

Scan the file filename for heredoc strings, and write the normalized heredoc strings to the file outputfile. The scan session uses a fresh yyscan_t object, so any nested (recursive, in a way) calls of this function are handled fine, as each invocation has its own state. After the file filename is processed, all resources are released.