aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/zconf.l
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-12-11 20:01:09 +0900
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-12-22 00:25:56 +0900
commit4b31a32caf0a28e4726f1bf267ff8a804ed864e2 (patch)
treedae9a7d23fc26f0ce97cafe4311b4f8d74c78d92 /scripts/kconfig/zconf.l
parentkconfig: switch to ASSIGN_VAL state in the second lexer (diff)
downloadlinux-dev-4b31a32caf0a28e4726f1bf267ff8a804ed864e2.tar.xz
linux-dev-4b31a32caf0a28e4726f1bf267ff8a804ed864e2.zip
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/zconf.l')
-rw-r--r--scripts/kconfig/zconf.l20
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_-]
<COMMAND>{
{n}+ {
const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
- current_pos.file = current_file;
- current_pos.lineno = yylineno;
if (id && id->flags & TF_COMMAND) {
BEGIN(PARAM);
return id->token;
@@ -285,9 +283,21 @@ int yylex(void)
repeat:
token = yylex1();
- /* Do not pass unneeded T_EOL to the parser. */
- if ((prev_token == T_EOL || prev_token == T_HELPTEXT) && token == T_EOL)
- goto repeat;
+ if (prev_token == T_EOL || prev_token == T_HELPTEXT) {
+ if (token == T_EOL) {
+ /* Do not pass unneeded T_EOL to the parser. */
+ goto repeat;
+ } else {
+ /*
+ * For the parser, update file/lineno at the first token
+ * of each statement. Generally, \n is a statement
+ * terminator in Kconfig, but it is not always true
+ * because \n could be escaped by a backslash.
+ */
+ current_pos.file = current_file;
+ current_pos.lineno = yylineno;
+ }
+ }
if (prev_prev_token == T_EOL && prev_token == T_WORD &&
(token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL))