summaryrefslogtreecommitdiff
path: root/glcpp-lex.l
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2010-05-13 10:46:29 -0700
committerCarl Worth <cworth@cworth.org>2010-05-14 09:48:14 -0700
commit48b94da0994b44e41324a2419117dcd81facce8b (patch)
tree2e30fe4a2b5e6eb953dbb37fadaa916f4f79d284 /glcpp-lex.l
parent462cce1852c80a2d71bfec1a2ead10fe0a9e2486 (diff)
Make the lexer return SPACE tokens unconditionally.
It seems strange to always be returning SPACE tokens, but since we were already needing to return a SPACE token in some cases, this actually simplifies our lexer. This also allows us to fix two whitespace-handling differences compared to "gcc -E" so that now the recent modification to the test suite passes once again.
Diffstat (limited to 'glcpp-lex.l')
-rw-r--r--glcpp-lex.l29
1 files changed, 3 insertions, 26 deletions
diff --git a/glcpp-lex.l b/glcpp-lex.l
index 3c9dda46d4..21b9e3530a 100644
--- a/glcpp-lex.l
+++ b/glcpp-lex.l
@@ -32,9 +32,6 @@
%option reentrant noyywrap
%option extra-type="glcpp_parser_t *"
-%x ST_DEFINE
-%x ST_DEFVAL
-
SPACE [[:space:]]
NONSPACE [^[:space:]]
NEWLINE [\n]
@@ -55,31 +52,9 @@ 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))
@@ -109,6 +84,8 @@ TOKEN [^[:space:](),]+
return NEWLINE;
}
-{SPACE}+
+{HSPACE}+ {
+ return SPACE;
+}
%%