diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-12-11 06:01:09 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-12-21 10:25:56 -0500 |
commit | 4b31a32caf0a28e4726f1bf267ff8a804ed864e2 (patch) | |
tree | dae9a7d23fc26f0ce97cafe4311b4f8d74c78d92 /scripts/kconfig | |
parent | 824fa3b3b5e3647de0530328e8734c24418eec49 (diff) |
kconfig: update current_pos in the second lexer
To simplify the generated lexer, let the hand-made lexer update the
file name and line number for the parser.
I tested this with DEBUG_PARSE, and confirmed the same file names
and line numbers were dumped.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r-- | scripts/kconfig/zconf.l | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 05e2d95e3b22..9b083a176fb4 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -101,8 +101,6 @@ n [A-Za-z0-9_-] | |||
101 | <COMMAND>{ | 101 | <COMMAND>{ |
102 | {n}+ { | 102 | {n}+ { |
103 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); | 103 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); |
104 | current_pos.file = current_file; | ||
105 | current_pos.lineno = yylineno; | ||
106 | if (id && id->flags & TF_COMMAND) { | 104 | if (id && id->flags & TF_COMMAND) { |
107 | BEGIN(PARAM); | 105 | BEGIN(PARAM); |
108 | return id->token; | 106 | return id->token; |
@@ -285,9 +283,21 @@ int yylex(void) | |||
285 | repeat: | 283 | repeat: |
286 | token = yylex1(); | 284 | token = yylex1(); |
287 | 285 | ||
288 | /* Do not pass unneeded T_EOL to the parser. */ | 286 | if (prev_token == T_EOL || prev_token == T_HELPTEXT) { |
289 | if ((prev_token == T_EOL || prev_token == T_HELPTEXT) && token == T_EOL) | 287 | if (token == T_EOL) { |
290 | goto repeat; | 288 | /* Do not pass unneeded T_EOL to the parser. */ |
289 | goto repeat; | ||
290 | } else { | ||
291 | /* | ||
292 | * For the parser, update file/lineno at the first token | ||
293 | * of each statement. Generally, \n is a statement | ||
294 | * terminator in Kconfig, but it is not always true | ||
295 | * because \n could be escaped by a backslash. | ||
296 | */ | ||
297 | current_pos.file = current_file; | ||
298 | current_pos.lineno = yylineno; | ||
299 | } | ||
300 | } | ||
291 | 301 | ||
292 | if (prev_prev_token == T_EOL && prev_token == T_WORD && | 302 | if (prev_prev_token == T_EOL && prev_token == T_WORD && |
293 | (token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL)) | 303 | (token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL)) |