static list *new_list(char const *const first_item)
- Create a new list node.
The specified item is assigned to the node's value.
Returns the newly created node.
static list *add_item(list *const L, char const *const item)
- Add a new item to the specified list.
The item is added at the back of the list,
so items added are kept in order.
- A pointer to the beginning of the list is returned (the same as was specified).
static void include_file(char const *const filename, lexer_state *const lexer, int currentline)
- Process the specified file.
static void update_unique_id(lexer_state *const lexer)
static void expand(yyscan_t yyscanner, macro_def *const macro, list *args, lexer_state *const lexer)
- Expand the specified macro (or constant).
static void define_constant(constant_table *const table, char const *const name, char const *const value)
void define_macro(constant_table *const table, char *const name, list *const parameters)
- Define a macro by the given name,
parameters and body.
macro_def *find_macro(constant_table *const table, char *const name)
- Find the specified macro.
If the specified macro does not exist,
NULL is returned.
static char const *concat(char const *str1, char const *str2, int need_space)
- Concatenate two strings,
and return the result.
If the first string is NULL,
then the result consists of the second string.
If need_space is true,
a space is inserted between the two strings.
static char *concatn(int need_space, unsigned numargs, ...)
- Concatenate
numargs
strings together into one new string.
If need_space
is non-zero,
the strings are separated by a space.
static void emit(lexer_state *const lexer, char const *const str)
- Emit the specified string.
This function will be the "gateway" to the output file.
All tokens except
.sub
,
.end
and .namespace
are indented.
All tokens are separated with a space,
)
,
]
,
,
.
static void emitf(lexer_state *const lexer, char const *const str, ...)
new_constant_table
pop_constant_table
delete_constant_table
munge_id
- Generate an identifier based on a macro label or locaal declaration,
or a macro label or local expansion.
- A label declaration looks like: ".label $LABEL:",
from which a normal PIR label is created,
formatted as: "_unique_MACRO_LABEL_?:".
- A label expansion looks like ".$LABEL",
from which a label identifier is generated,
formatted as: "_unique_MACRO_LABEL_?" (note the difference,
there is no colon at the end.
- The same works for local identifiers,
but of course the is_label_declaration argument must be 0 for that.
static void process_string(char *const buffer, lexer_state *const lexer)
- Process the string stored in
buffer
.
First a new yyscan_t object is created,
initialized,
after which the specified buffer is parsed.
Afterwards the yyscan_t object is destroyed.
static void process_file(char const *const filename, lexer_state *const lexer)
- Process the specified file.
static void print_help(char const *const programname)
int yyerror(yyscan_t yyscanner, lexer_state *const lexer, char const *const message, ...)
- Function for syntax error handling.
int main(int argc, char *argv[])
- Pre-processor main function.
|
|