diff options
Diffstat (limited to 'glcpp-lex.l')
-rw-r--r-- | glcpp-lex.l | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/glcpp-lex.l b/glcpp-lex.l index 21b9e3530a..3c9dda46d4 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -32,6 +32,9 @@ %option reentrant noyywrap %option extra-type="glcpp_parser_t *" +%x ST_DEFINE +%x ST_DEFVAL + SPACE [[:space:]] NONSPACE [^[:space:]] NEWLINE [\n] @@ -52,9 +55,31 @@ TOKEN [^[:space:](),]+ * "#define foo()" from "#define foo ()". */ {HASH}define{HSPACE}* { + BEGIN ST_DEFINE; return DEFINE; } +<ST_DEFINE>{IDENTIFIER} { + BEGIN ST_DEFVAL; + yylval.str = xtalloc_strdup (yyextra, yytext); + return IDENTIFIER; +} + +<ST_DEFVAL>\n { + BEGIN INITIAL; + return NEWLINE; +} + +<ST_DEFVAL>{HSPACE}+ { + BEGIN INITIAL; + return SPACE; +} + +<ST_DEFVAL>"(" { + BEGIN INITIAL; + return '('; +} + {IDENTIFIER} { yylval.str = xtalloc_strdup (yyextra, yytext); switch (glcpp_parser_macro_type (yyextra, yylval.str)) @@ -84,8 +109,6 @@ TOKEN [^[:space:](),]+ return NEWLINE; } -{HSPACE}+ { - return SPACE; -} +{SPACE}+ %% |