Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+15 -5
+15 -5
scripts/kconfig/zconf.l
··· 101 101 <COMMAND>{ 102 102 {n}+ { 103 103 const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); 104 - current_pos.file = current_file; 105 - current_pos.lineno = yylineno; 106 104 if (id && id->flags & TF_COMMAND) { 107 105 BEGIN(PARAM); 108 106 return id->token; ··· 283 285 repeat: 284 286 token = yylex1(); 285 287 286 - /* Do not pass unneeded T_EOL to the parser. */ 287 - if ((prev_token == T_EOL || prev_token == T_HELPTEXT) && token == T_EOL) 288 - goto repeat; 288 + if (prev_token == T_EOL || prev_token == T_HELPTEXT) { 289 + if (token == T_EOL) { 290 + /* Do not pass unneeded T_EOL to the parser. */ 291 + goto repeat; 292 + } else { 293 + /* 294 + * For the parser, update file/lineno at the first token 295 + * of each statement. Generally, \n is a statement 296 + * terminator in Kconfig, but it is not always true 297 + * because \n could be escaped by a backslash. 298 + */ 299 + current_pos.file = current_file; 300 + current_pos.lineno = yylineno; 301 + } 302 + } 289 303 290 304 if (prev_prev_token == T_EOL && prev_token == T_WORD && 291 305 (token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL))