From patchwork Tue Dec 11 11:01:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 153429 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp475434ljp; Tue, 11 Dec 2018 03:02:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uw7XyFyojbUBfb8a6Q8wTWrGLx6Wfkizr0I66TjyltKax+UW9zNEWsIMXBnFG0nbOufWlx X-Received: by 2002:a62:4e83:: with SMTP id c125mr16051308pfb.101.1544526149485; Tue, 11 Dec 2018 03:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544526149; cv=none; d=google.com; s=arc-20160816; b=cH/Us42Qpv27SmXHs0R48ScKGhfwv5tLoj6m1ytdqHBwyb6mafrZ5Ww7EU7UoA5Mm8 YpXtYtMRCV+63kZcThgrNXs1BBXgvIq0Uab/nnc/9fJC/v4GKesh4iQ1vgHYzHhc420K 2uQ3oM8ibuQNaGU47xhUslB5zoP4B+zr9QOa+CfsVEsA3a/+OgMO3DUC5doiYuS1AUO6 u4blVRIOqITg9VNKdBRlJ2PT075aTI2Z90bB9HixJ2Bv6/KcAOMbszIBT/JqoXHRCZHD x030bXyIO/yzrWgxEkg5LP3l4m0Spsm0uI4zZeVCOda/SZP20nYh/TFFOuwKU4ltuAnk Ycmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=H7uIjhRZd78YuhKatcgyhcv31egGnNdh5y9Y0vrPiac=; b=R/lKNvFDFS8WYibIQeqfpCzY3zz6EvnNzNu9VnKRT23eQxpQ4OZWZgBNDSKwpDqXbp /gM0yrBMkXttQKRdNeCa3EcOj6cu6Gs3mGHEsEfGXrO0MvEZ5gsvcZHrtZNQmU4ap081 TpsVS2/Gvi8kfkOyWAw+vYkONe7aatS9yB91+ZjLPx5fo3od/4Hn+xEM4K0Hje8mczPc QeeYEPFCJwe9vvtVgLkUGuz1jTW9aFnRkeDBA9YirxdZtFkcgwySKXUvtyb9GS3oABO7 HfI4KxnC7Wo2McXXEPtxyqGx33vMDxWJwfBmtwISo1e93mltwG+fH3JhBSQVIWRRWzIC EGdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=FUBA9gOB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20si11126530pgk.103.2018.12.11.03.02.29; Tue, 11 Dec 2018 03:02:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=FUBA9gOB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726824AbeLKLC1 (ORCPT + 31 others); Tue, 11 Dec 2018 06:02:27 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:36853 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726705AbeLKLBs (ORCPT ); Tue, 11 Dec 2018 06:01:48 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id wBBB1C63017210; Tue, 11 Dec 2018 20:01:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com wBBB1C63017210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544526092; bh=H7uIjhRZd78YuhKatcgyhcv31egGnNdh5y9Y0vrPiac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FUBA9gOBQNlZQC+gbVwyI/JVuq2QwxVbg4+BTaUgI5eWsBKric0VcEtND1MKaxGVw p4VUq9iVDrh9e9GUD5YxVvLxjqiU/C8yabrIFv/az7eJ3Q3oGtaBW2C+aoo8BNPZLQ afdAVOtDI55NTh4DgADa+xvm/DXTZMepBthKzxhvrG2p1OtIx5bu3ls8MsFLH6Q+kI 0v9x1LWWZPW27rl6UN2HA+zdPHx06iUVAlJpZghLoM6Gku/RID9Mzc4I/ajSdrp0Bl d3V8kmZI5BDHqH6/CWFCUrYJ0bYWQGrooxHgPfntnPSs9IE6PMfx69weLiiyIvkQ2N 8Zmaa7A+0sVwg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Ulf Magnusson , linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 26/27] kconfig: update current_pos in the second lexer Date: Tue, 11 Dec 2018 20:01:09 +0900 Message-Id: <1544526070-16690-27-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544526070-16690-1-git-send-email-yamada.masahiro@socionext.com> References: <1544526070-16690-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- scripts/kconfig/zconf.l | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index d462507..f0734abe 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -108,8 +108,6 @@ n [A-Za-z0-9_-] { {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; @@ -291,9 +289,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))