From 6c81f0a3909cb4b98c246086cd1a54d27b255b10 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sun, 25 May 2008 21:46:17 -0700 Subject: [PATCH] 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". --- preproc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/preproc.c b/preproc.c index c244e8c5..d45881b8 100644 --- a/preproc.c +++ b/preproc.c @@ -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; -- 2.11.4.GIT