From patchwork Tue Dec 11 11:00:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 153420 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp474605ljp; Tue, 11 Dec 2018 03:01:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/UDvj0EycFVArYwbjoh8j+S4klcapM2SVB+nUkeTkbKdHOLUQWbj8DGA0EMfRpxH9mE6+BF X-Received: by 2002:a17:902:8f83:: with SMTP id z3mr15176962plo.328.1544526106797; Tue, 11 Dec 2018 03:01:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544526106; cv=none; d=google.com; s=arc-20160816; b=IBGV45X3DyTTiBkrKW28QJCv59MGouyvKgAxxFNpAxLBoCNQGiZAWgQI3VI8G8CYo2 FRzdIz9AkuJUdv4h8GkSfBTLSa1FEbHwDAKJbVpGh3D2s9Gub7mQDZ9lCKIsZju4+BqA cczpjrRoY8ty/pUc93W7g6oHEvyOrL49moPSL2hNtrWwOpraDyWInPHm3M1w1V9gQEpI sIfloLv9BN3Tdy8RE+Vcao8bqLcXUkOcU+QhOJquHF7KqxstZ36lUTwgYE5B5TZ9r5CL vfUUFwX/VKO7vKTwR4kq+IDMxeCzvDv4ZawXGvmyh2KuSdyWnbemAql/7zpAeAGKTRo9 EzSg== 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=iNmCjGIrzgz6jSnY2pvpjlrVb4D8VRpuL9G+9Lp30As=; b=sTqbXQWz1p9rnQpsE7QZRYdoGNcHcEOLE7J2SeZRexk8Hw9RpwCNk0gdtMimJB9/Ag Rbe8KVm8vTztdyNyVQpdo42CjTH/1Z8ORXyiSHIl2MfIkImwrBbn/uMa1/td+LJffC/+ BJt2bUh3uNe1U6dw+OnO2EZY3RfV3cYrA+hcDjYfTXCAXa+VLFdYwG8Pq6UxEiprs5LZ hhAyrtmUWvfIW3fnHw4+U9PLaWKVHWH+Ld8XFiM72bgOEf6IN9hR6QsTS4YnX8VWsY+V JawH7xOOhokU2cPxgRehrxJY+IWJhv6qWXFqsEEKVmgN/FNRlNxkT23fdY1WWp1qj6y2 wnUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=BrC0ZLWv; 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 o2si12985331pfb.166.2018.12.11.03.01.46; Tue, 11 Dec 2018 03:01:46 -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=BrC0ZLWv; 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 S1726697AbeLKLBo (ORCPT + 31 others); Tue, 11 Dec 2018 06:01:44 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:36639 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726469AbeLKLBm (ORCPT ); Tue, 11 Dec 2018 06:01:42 -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 wBBB1C5k017210; Tue, 11 Dec 2018 20:01:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com wBBB1C5k017210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544526079; bh=iNmCjGIrzgz6jSnY2pvpjlrVb4D8VRpuL9G+9Lp30As=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BrC0ZLWvRAna3/LVGAwk2xylPzxljOlcd89yaJUcQgdso53UDFXQUYrBvMyarImXy edydHjjz2LO4QMZ2zNrJ8c/A2dwK6wwC+jooYlRwX9R4tFDODf6co72JODXF5W/eep PHjHTESyqBfRjXAOQkzGtn+G5lvKeywVIo++jbE6HvJ5/6e6DyL6FZ3h4cAN2cX+sH IR8FKsMFqxSXTQPjov3Y0dyqILcG6MmOMFySPW7aljn+EfPad7u7WHTnyJMbo5vgtG ERXIgVTtXLjgj6CDqpHZdAyMEbt79RzWVA3HHK3nBeDCqyEMyRNMhaCcDogqT+KesS VYKOQzzN7KK7g== 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 09/27] kconfig: remove grammatically ambiguous "unexpected option" diagnostic Date: Tue, 11 Dec 2018 20:00:52 +0900 Message-Id: <1544526070-16690-10-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 This commit decreases 15 shift/reduce conflicts. The location of this error recovery is ambiguous. For example, there are two ways to interpret the following code: 1 config FOO 2 bool "foo" [A] Both lines are reduced together into a config_stmt. [B] The only line 1 is reduced into a config_stmt, and the line 2 matches to "option_name error T_EOL" Of course, we expect [A], but [B] could be grammatically possible. Kconfig has no terminator for a config block. So, we cannot detect its end until we see non-property keywords. People often insert a blank line between two config blocks, but it is just a coding convention. Blank lines are actually allowed anywhere in Kconfig files. The real error is when a property keyword appears right after "endif", "endchoice", "endmenu", "source", "comment", or variable assignments. Instead of fixing the grammatical ambiguity, I chose to simply remove this error recovery. The difference is unexpected option "bool" ... is turned into a more generic message: invalid statement Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.y | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 02bfc62..cef6123 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE]; static struct menu *current_menu, *current_entry; %} -%expect 21 +%expect 6 %union { @@ -94,7 +94,6 @@ static struct menu *current_menu, *current_entry; %type expr %type if_expr %type end -%type option_name %type if_entry menu_entry choice_entry %type symbol_option_arg word_opt assign_val @@ -127,17 +126,9 @@ stmt_list: | stmt_list menu_stmt | stmt_list end { zconf_error("unexpected end statement"); } | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } - | stmt_list option_name error T_EOL -{ - zconf_error("unexpected option \"%s\"", $2->name); -} | stmt_list error T_EOL { zconf_error("invalid statement"); } ; -option_name: - T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_IMPLY | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE -; - common_stmt: if_stmt | comment_stmt