summaryrefslogtreecommitdiff
path: root/glcpp-lex.l
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2010-05-20 08:01:44 -0700
committerCarl Worth <cworth@cworth.org>2010-05-20 08:01:44 -0700
commitb569383bbdfa22ed591255f56fb93832633a95ae (patch)
tree04a52c022ccec5658c0fac901f427fefafbadc17 /glcpp-lex.l
parent472524413d004680dbdb89602617f32da8f42f56 (diff)
Avoid re-expanding a macro name that has once been rejected from expansion.
The specification of the preprocessor in C99 says that when we see a macro name that we are already expanding that we refuse to expand it now, (which we've done for a while), but also that we refuse to ever expand it later if seen in other contexts at which it would be legitimate to expand. We add a test case for that here, and fix it to work. The fix takes advantage of a new token_t value for tokens and argument words along with the recently added IDENTIFIER_FINALIZED token type which instructs the parser to not even look for another expansion.
Diffstat (limited to 'glcpp-lex.l')
-rw-r--r--glcpp-lex.l12
1 files changed, 9 insertions, 3 deletions
diff --git a/glcpp-lex.l b/glcpp-lex.l
index aec9679..8e3ab66 100644
--- a/glcpp-lex.l
+++ b/glcpp-lex.l
@@ -114,12 +114,14 @@ TOKEN [^[:space:](),]+
<ST_DEFINE_PARAMETER>{HSPACE}+
<ST_DEFINE_VALUE>{TOKEN} {
- yylval.str = xtalloc_strdup (yyextra, yytext);
+ yylval.token.type = TOKEN;
+ yylval.token.value = xtalloc_strdup (yyextra, yytext);
return TOKEN;
}
<ST_DEFINE_VALUE>[(),] {
- yylval.str = xtalloc_strdup (yyextra, yytext);
+ yylval.token.type = TOKEN;
+ yylval.token.value = xtalloc_strdup (yyextra, yytext);
return TOKEN;
}
@@ -147,6 +149,9 @@ TOKEN [^[:space:](),]+
case TOKEN_CLASS_IDENTIFIER:
return IDENTIFIER;
break;
+ case TOKEN_CLASS_IDENTIFIER_FINALIZED:
+ return IDENTIFIER_FINALIZED;
+ break;
case TOKEN_CLASS_FUNC_MACRO:
return FUNC_MACRO;
break;
@@ -162,7 +167,8 @@ TOKEN [^[:space:](),]+
}
{TOKEN} {
- yylval.str = xtalloc_strdup (yyextra, yytext);
+ yylval.token.type = TOKEN;
+ yylval.token.value = xtalloc_strdup (yyextra, yytext);
return TOKEN;
}