kconfig: switch to ASSIGN_VAL state in the second lexer
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Tue, 11 Dec 2018 11:01:08 +0000 (20:01 +0900)
committerChristian Lamparter <chunkeey@gmail.com>
Sun, 10 Feb 2019 21:32:20 +0000 (22:32 +0100)
To simplify the generated lexer, switch to the ASSIGN_VAL state in
the hand-made lexer.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
config/zconf.l

index 1cf9ac42806f09fcfcbc0ca6ab9ba4a55ed9767b..5341e5431f3b22024865989a0bf565adb3b95ea9 100644 (file)
@@ -25,6 +25,7 @@ static struct {
        int lineno;
 } current_pos;
 
+static int prev_prev_token = T_EOL;
 static int prev_token = T_EOL;
 static char *text;
 static int text_size, text_asize;
@@ -117,9 +118,9 @@ n   [A-Za-z0-9_-]
                        return T_WORD;
                free(yylval.string);
        }
-       "="     { BEGIN(ASSIGN_VAL); return T_EQUAL; }
-       ":="    { BEGIN(ASSIGN_VAL); return T_COLON_EQUAL; }
-       "+="    { BEGIN(ASSIGN_VAL); return T_PLUS_EQUAL; }
+       "="     return T_EQUAL;
+       ":="    return T_COLON_EQUAL;
+       "+="    return T_PLUS_EQUAL;
        [[:blank:]]+
        .       warn_ignored_character(*yytext);
        \n      {
@@ -288,6 +289,11 @@ repeat:
        if ((prev_token == T_EOL || prev_token == T_HELPTEXT) && token == T_EOL)
                goto repeat;
 
+       if (prev_prev_token == T_EOL && prev_token == T_WORD &&
+           (token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL))
+               BEGIN(ASSIGN_VAL);
+
+       prev_prev_token = prev_token;
        prev_token = token;
 
        return token;