diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-05-25 21:46:17 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-05-25 21:46:17 -0700 |
commit | 6c81f0a3909cb4b98c246086cd1a54d27b255b10 (patch) | |
tree | 6b98091383ca280f8ca09d25a17627e3ad7e36af /preproc.c | |
parent | 1df0b9ee2d7f87e5e194343227cfe9cdcc41ac12 (diff) | |
download | nasm-6c81f0a3909cb4b98c246086cd1a54d27b255b10.tar.gz nasm-6c81f0a3909cb4b98c246086cd1a54d27b255b10.tar.bz2 nasm-6c81f0a3909cb4b98c246086cd1a54d27b255b10.zip |
Implement %? and %?? for smacros
%? - substitute the macro name as invoked
%?? - substitute the macro name as defined
In particular:
%idefine keyword $%?
... can be used to make a new keyword "disappear".
Diffstat (limited to 'preproc.c')
-rw-r--r-- | preproc.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -155,8 +155,10 @@ struct Context { enum pp_token_type { TOK_NONE = 0, TOK_WHITESPACE, TOK_COMMENT, TOK_ID, TOK_PREPROC_ID, TOK_STRING, - TOK_NUMBER, TOK_FLOAT, TOK_SMAC_END, TOK_OTHER, TOK_SMAC_PARAM, - TOK_INTERNAL_STRING + TOK_NUMBER, TOK_FLOAT, TOK_SMAC_END, TOK_OTHER, + TOK_INTERNAL_STRING, + TOK_PREPROC_Q, TOK_PREPROC_QQ, + TOK_SMAC_PARAM /* MUST BE LAST IN THE LIST!!! */ }; struct Token { @@ -766,6 +768,13 @@ static Token *tokenize(char *line) if (*p) p++; type = TOK_PREPROC_ID; + } else if (*p == '?') { + type = TOK_PREPROC_Q; /* %? */ + p++; + if (*p == '?') { + type = TOK_PREPROC_QQ; /* %?? */ + p++; + } } else if (isidchar(*p) || ((*p == '!' || *p == '%' || *p == '$') && isidchar(p[1]))) { @@ -3260,6 +3269,12 @@ again: ttt = ttt->next; } tline = pcopy; + } else if (t->type == TOK_PREPROC_Q) { + tt = new_Token(tline, TOK_ID, mname, 0); + tline = tt; + } else if (t->type == TOK_PREPROC_QQ) { + tt = new_Token(tline, TOK_ID, m->name, 0); + tline = tt; } else { tt = new_Token(tline, t->type, t->text, 0); tline = tt; |