return (token); \
} while(0)
+#define RETURN_STRING_TOKEN(token) \
+ do { \
+ yylval->str = ralloc_strdup (yyextra, yytext); \
+ RETURN_TOKEN (token); \
+ } while(0)
+
%}
%option bison-bridge bison-locations reentrant noyywrap
}
{HASH}version{HSPACE}+ {
- yylval->str = ralloc_strdup (yyextra, yytext);
yyextra->space_tokens = 0;
- RETURN_TOKEN (HASH_VERSION);
+ RETURN_STRING_TOKEN (HASH_VERSION);
}
/* glcpp doesn't handle #extension, #version, or #pragma directives.
* Simply pass them through to the main compiler's lexer/parser. */
{HASH}(extension|pragma)[^\n]* {
- yylval->str = ralloc_strdup (yyextra, yytext);
yylineno++;
yycolumn = 0;
- RETURN_TOKEN (OTHER);
+ RETURN_STRING_TOKEN (OTHER);
}
{HASH}line{HSPACE}+ {
/* An identifier immediately followed by '(' */
<DEFINE>{IDENTIFIER}/"(" {
yy_pop_state(yyscanner);
- yylval->str = ralloc_strdup (yyextra, yytext);
- RETURN_TOKEN (FUNC_IDENTIFIER);
+ RETURN_STRING_TOKEN (FUNC_IDENTIFIER);
}
/* An identifier not immediately followed by '(' */
<DEFINE>{IDENTIFIER} {
yy_pop_state(yyscanner);
- yylval->str = ralloc_strdup (yyextra, yytext);
- RETURN_TOKEN (OBJ_IDENTIFIER);
+ RETURN_STRING_TOKEN (OBJ_IDENTIFIER);
}
/* Whitespace */
<DEFINE>[/][^*]{NONSPACE}* {
BEGIN INITIAL;
glcpp_error(yylloc, yyextra, "#define followed by a non-identifier: %s", yytext);
- RETURN_TOKEN (INTEGER_STRING);
+ RETURN_STRING_TOKEN (INTEGER_STRING);
}
/* A character that can't start an identifier, comment, or
<DEFINE>[^_a-zA-Z/[:space:]]{NONSPACE}* {
BEGIN INITIAL;
glcpp_error(yylloc, yyextra, "#define followed by a non-identifier: %s", yytext);
- RETURN_TOKEN (INTEGER_STRING);
+ RETURN_STRING_TOKEN (INTEGER_STRING);
}
{HASH}undef {
}
{DECIMAL_INTEGER} {
- yylval->str = ralloc_strdup (yyextra, yytext);
- RETURN_TOKEN (INTEGER_STRING);
+ RETURN_STRING_TOKEN (INTEGER_STRING);
}
{OCTAL_INTEGER} {
- yylval->str = ralloc_strdup (yyextra, yytext);
- RETURN_TOKEN (INTEGER_STRING);
+ RETURN_STRING_TOKEN (INTEGER_STRING);
}
{HEXADECIMAL_INTEGER} {
- yylval->str = ralloc_strdup (yyextra, yytext);
- RETURN_TOKEN (INTEGER_STRING);
+ RETURN_STRING_TOKEN (INTEGER_STRING);
}
"<<" {
}
{IDENTIFIER} {
- yylval->str = ralloc_strdup (yyextra, yytext);
- RETURN_TOKEN (IDENTIFIER);
+ RETURN_STRING_TOKEN (IDENTIFIER);
}
{PP_NUMBER} {
- yylval->str = ralloc_strdup (yyextra, yytext);
- RETURN_TOKEN (OTHER);
+ RETURN_STRING_TOKEN (OTHER);
}
{PUNCTUATION} {
}
{OTHER}+ {
- yylval->str = ralloc_strdup (yyextra, yytext);
- RETURN_TOKEN (OTHER);
+ RETURN_STRING_TOKEN (OTHER);
}
{HSPACE} {