mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-19 18:00:23 +08:00
pptok: add rmacro/rimacro
preproc: revamp for use with rmacro/rimacro instead of overloading macro/imacro with optional recursion parameter
This commit is contained in:
parent
8059902f12
commit
0af5ee2732
@ -59,6 +59,7 @@
|
||||
%endmacro
|
||||
%endrep
|
||||
%error
|
||||
%exitmacro
|
||||
%exitrep
|
||||
%fatal
|
||||
%iassign
|
||||
@ -76,6 +77,8 @@
|
||||
%push
|
||||
%rep
|
||||
%repl
|
||||
%rimacro
|
||||
%rmacro
|
||||
%rotate
|
||||
%stacksize
|
||||
%strcat
|
||||
|
27
preproc.c
27
preproc.c
@ -1928,7 +1928,6 @@ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive)
|
||||
def->plus = false;
|
||||
def->nolist = false;
|
||||
def->in_progress = 0;
|
||||
def->max_depth = 0;
|
||||
def->rep_nest = NULL;
|
||||
def->nparam_min = 0;
|
||||
def->nparam_max = 0;
|
||||
@ -1972,25 +1971,6 @@ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive)
|
||||
def->nolist = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle maximum recursion depth.
|
||||
*/
|
||||
if (tline && tok_is_(tline->next, ",")) {
|
||||
tline = tline->next->next;
|
||||
if (tok_is_(tline, "*")) {
|
||||
def->max_depth = 65536; /* should we eliminate this? */
|
||||
} else if (!tok_type_(tline, TOK_NUMBER)) {
|
||||
error(ERR_NONFATAL,
|
||||
"`%s' expects a maximum recursion depth after `,'", directive);
|
||||
} else {
|
||||
def->max_depth = readnum(tline->text, &err);
|
||||
if (err) {
|
||||
error(ERR_NONFATAL, "unable to parse maximum recursion depth `%s'",
|
||||
tline->text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle default parameters.
|
||||
*/
|
||||
@ -2062,6 +2042,7 @@ static int do_directive(Token * tline)
|
||||
int64_t count;
|
||||
size_t len;
|
||||
int severity;
|
||||
bool is_recursive = false;
|
||||
|
||||
origline = tline;
|
||||
|
||||
@ -2608,7 +2589,10 @@ static int do_directive(Token * tline)
|
||||
nasm_free(cond);
|
||||
free_tlist(origline);
|
||||
return DIRECTIVE_FOUND;
|
||||
|
||||
|
||||
case PP_RMACRO:
|
||||
case PP_RIMACRO:
|
||||
is_recursive = true;
|
||||
case PP_MACRO:
|
||||
case PP_IMACRO:
|
||||
if (defining) {
|
||||
@ -2618,6 +2602,7 @@ static int do_directive(Token * tline)
|
||||
return DIRECTIVE_FOUND;
|
||||
}
|
||||
defining = nasm_malloc(sizeof(MMacro));
|
||||
defining->max_depth = (is_recursive ? 65536 : 0); /* remove/change this??? */
|
||||
defining->casesense = (i == PP_MACRO);
|
||||
if (!parse_mmacro_spec(tline, defining, pp_directives[i])) {
|
||||
nasm_free(defining);
|
||||
|
Loading…
x
Reference in New Issue
Block a user