lexer_state *new_lexer(char *const filename)
- Constructor for a lexer structure.
Initializes all fields,
creates a Parrot interpreter structure.
void pirerror(lexer_state *const lexer, char const *const message, ...)
- General error function,
if
yyerror()
is not desirable (not a parse error) or not possible (if no access to the parser's yyscanner
object).
- Write an error message to
stderr
and increment number of errors.
char *dupstr(char const *const source)
- The C89 standard does not define a strdup() in the C library,
so define our own strdup.
Function names beginning with "str" are reserved,
so make it dupstr,
as that is what it does: duplicate a string.
char *dupstrn(char const *const source, size_t num_chars)
- See dupstr,
except that this version takes the number of characters to be copied.
Easy for copying a string except the quotes,
for instance.
void release_resources(lexer_state *lexer)