From patchwork Tue Dec 11 11:01:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 153432 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp475930ljp; Tue, 11 Dec 2018 03:02:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vj9qj1GupXDIhZxd0auo+kpWOwPISBk0dqRA1AF3uC7KL5Yt/lHQiZg/2kRCPaLYCf4G4V X-Received: by 2002:a17:902:708b:: with SMTP id z11mr15630423plk.203.1544526176886; Tue, 11 Dec 2018 03:02:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544526176; cv=none; d=google.com; s=arc-20160816; b=AMUlLQ2Rhr+SPGQlpCDCxrJW3dpKfsIoaOZwD4Vmn3QWRyMDPO4BTKjG322uI9Y6pA Zqg15BA4C3lYuaPBKjqZVZcRkhpMuMJW8dUIcNCxGv8iR0mrReyPGHU0qWusVo1WUxAs N8ymBICRvlrx4JIi5XQic9fUqkM0ButPL+3Zwv4wqmoWb2e0z+3DWiHUfP/5vvXevh3O WuSWjq8l9td3YK3DouZkDdDZd/Jwhoxx2f4OtuyOaKR//Q7SmLjnInTc4oZrtnPk9vIA CFZxumlrbn6EN7c2En/ewlmVOfye3nFdOvGo3Z/y+f3UmRGIq54LifKPxSXB9bqPOjN1 KHEA== 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=J02b+9Zj+B1p1FUXXgB3BFEcLl7iHu0uQ5OSwehpRuc=; b=kWSYA6zLB5CwXdJhgEb6w/BmnTE4iGh77NmbhbRvuZuF4PwZspMgqXKTEAHNhc5afE Cwa3OAzhCCwHKsKe9X1ZV5KnPRFVlMyfeRAYnAEG3hIMTz9i+j6uIOJHTQQ+Il1a3j6o 9gkgZAMBnCg6VuS4XK45/g5Nb0fyHrEUV0WBFWeH7RE2sfb0WmgVQt6iR2C5NbuRXZiN uFOCmeXHFChIxYL0vG8DTfpkX2rCDGoZZdTdE4HA6Tpk3Hmss2ISuSxJm4g7u9Xnhh5E 2+H4F6/PgCi4XjC9vGq6X2amA7q6ibzn1y/t+It3MMZNGhGm9fNyoJDOZHK7k1FU+dI/ cdPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Z00SIdjL; 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 x15si12237529pgq.378.2018.12.11.03.02.56; Tue, 11 Dec 2018 03:02:56 -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=Z00SIdjL; 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 S1726843AbeLKLCs (ORCPT + 31 others); Tue, 11 Dec 2018 06:02:48 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:36717 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726620AbeLKLBn (ORCPT ); Tue, 11 Dec 2018 06:01:43 -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 wBBB1C5s017210; Tue, 11 Dec 2018 20:01:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com wBBB1C5s017210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544526085; bh=J02b+9Zj+B1p1FUXXgB3BFEcLl7iHu0uQ5OSwehpRuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z00SIdjLHCEj9f4UhYHhbGrQmDkm8Ucwpxly4GjBjq4vC3dq8njmE/cmA3R8waCe5 /tDKdNcOXLnotWWu3gHsWT4KIkbbSmuxB4J9UF7wILHZqb/OA+iwhjpqXEL/0t4ydJ lPyiHHtyxkc7RaW3lIYPlVtY+9yiuKLDxtLASzZ6ESFo2eMkQU2Nf8UVPLCjWAkn6t o9flduHBCJzSjsGP6xqSUFNJoJvCKgxgyfO8MvsHnlpQ6rSmlGgue7PP8TytQCXbGI ab7umbfKBcA/mY2hTKkv30TADvuKIHc3jQT+/IM8kVVRQVBH8xyH96CKQenP5czmgj rrSeTLOlOBX9A== 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 17/27] kconfig: refactor scanning and parsing "option" properties Date: Tue, 11 Dec 2018 20:01:00 +0900 Message-Id: <1544526070-16690-18-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 For the keywords "modules", "defconfig_list", and "allnoconfig_y", the lexer should pass specific tokens instead of generic T_WORD. This simplifies both the lexer and the parser. Signed-off-by: Masahiro Yamada --- scripts/kconfig/kconf_id.c | 3 --- scripts/kconfig/lkc.h | 9 +++------ scripts/kconfig/menu.c | 43 ++++++++++++++++++++----------------------- scripts/kconfig/zconf.l | 3 +++ scripts/kconfig/zconf.y | 35 +++++++++++++++-------------------- 5 files changed, 41 insertions(+), 52 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/kconf_id.c b/scripts/kconfig/kconf_id.c index ec2c011..f8b222c 100644 --- a/scripts/kconfig/kconf_id.c +++ b/scripts/kconfig/kconf_id.c @@ -30,9 +30,6 @@ static struct kconf_id kconf_id_array[] = { { "visible", T_VISIBLE, TF_COMMAND }, { "option", T_OPTION, TF_COMMAND }, { "on", T_ON, TF_PARAM }, - { "modules", T_OPT_MODULES, TF_OPTION }, - { "defconfig_list", T_OPT_DEFCONFIG_LIST, TF_OPTION }, - { "allnoconfig_y", T_OPT_ALLNOCONFIG_Y, TF_OPTION }, }; #define KCONF_ID_ARRAY_SIZE (sizeof(kconf_id_array)/sizeof(struct kconf_id)) diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index b6bbcd1..5f4880a 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -32,7 +32,6 @@ static inline const char *CONFIG_prefix(void) #define TF_COMMAND 0x0001 #define TF_PARAM 0x0002 -#define TF_OPTION 0x0004 enum conf_def_mode { def_default, @@ -42,10 +41,6 @@ enum conf_def_mode { def_random }; -#define T_OPT_MODULES 1 -#define T_OPT_DEFCONFIG_LIST 2 -#define T_OPT_ALLNOCONFIG_Y 4 - struct kconf_id { const char *name; int token; @@ -90,7 +85,9 @@ void menu_add_visibility(struct expr *dep); struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); -void menu_add_option(int token, char *arg); +void menu_add_option_modules(void); +void menu_add_option_defconfig_list(void); +void menu_add_option_allnoconfig_y(void); void menu_finalize(struct menu *parent); void menu_set_type(int type); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 4cf15d4..7e2b2c9 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -195,29 +195,26 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); } -void menu_add_option(int token, char *arg) -{ - switch (token) { - case T_OPT_MODULES: - if (modules_sym) - zconf_error("symbol '%s' redefines option 'modules'" - " already defined by symbol '%s'", - current_entry->sym->name, - modules_sym->name - ); - modules_sym = current_entry->sym; - break; - case T_OPT_DEFCONFIG_LIST: - if (!sym_defconfig_list) - sym_defconfig_list = current_entry->sym; - else if (sym_defconfig_list != current_entry->sym) - zconf_error("trying to redefine defconfig symbol"); - sym_defconfig_list->flags |= SYMBOL_NO_WRITE; - break; - case T_OPT_ALLNOCONFIG_Y: - current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y; - break; - } +void menu_add_option_modules(void) +{ + if (modules_sym) + zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'", + current_entry->sym->name, modules_sym->name); + modules_sym = current_entry->sym; +} + +void menu_add_option_defconfig_list(void) +{ + if (!sym_defconfig_list) + sym_defconfig_list = current_entry->sym; + else if (sym_defconfig_list != current_entry->sym) + zconf_error("trying to redefine defconfig symbol"); + sym_defconfig_list->flags |= SYMBOL_NO_WRITE; +} + +void menu_add_option_allnoconfig_y(void) +{ + current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y; } static int menu_validate_number(struct symbol *sym, struct symbol *sym2) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 5046d3c..0265502 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -147,6 +147,9 @@ n [A-Za-z0-9_-] } { + "modules" return T_MODULES; + "defconfig_list" return T_DEFCONFIG_LIST; + "allnoconfig_y" return T_ALLNOCONFIG_Y; "&&" return T_AND; "||" return T_OR; "(" return T_OPEN_PAREN; diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 4345f9f..8db9189 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -64,18 +64,21 @@ static struct menu *current_menu, *current_entry; %token T_IMPLY %token T_RANGE %token T_VISIBLE -%token T_OPTION %token T_ON %token T_WORD %token T_WORD_QUOTE +%token T_ALLNOCONFIG_Y %token T_BOOL %token T_CLOSE_PAREN %token T_DEFAULT +%token T_DEFCONFIG_LIST %token T_DEF_BOOL %token T_DEF_TRISTATE %token T_HEX %token T_INT +%token T_MODULES %token T_OPEN_PAREN +%token T_OPTION %token T_STRING %token T_TRISTATE %token T_EOL @@ -97,7 +100,7 @@ static struct menu *current_menu, *current_entry; %type if_expr %type end %type if_entry menu_entry choice_entry -%type symbol_option_arg word_opt assign_val +%type word_opt assign_val %destructor { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -172,7 +175,6 @@ menuconfig_stmt: menuconfig_entry_start config_option_list config_option_list: /* empty */ | config_option_list config_option - | config_option_list symbol_option | config_option_list depends | config_option_list help ; @@ -219,27 +221,20 @@ config_option: T_RANGE symbol symbol if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); }; -symbol_option: T_OPTION symbol_option_list T_EOL -; +config_option: T_OPTION T_MODULES T_EOL +{ + menu_add_option_modules(); +}; -symbol_option_list: - /* empty */ - | symbol_option_list T_WORD symbol_option_arg +config_option: T_OPTION T_DEFCONFIG_LIST T_EOL { - const struct kconf_id *id = kconf_id_lookup($2, strlen($2)); - if (id && id->flags & TF_OPTION) { - menu_add_option(id->token, $3); - free($3); - } - else - zconfprint("warning: ignoring unknown option %s", $2); - free($2); + menu_add_option_defconfig_list(); }; -symbol_option_arg: - /* empty */ { $$ = NULL; } - | T_EQUAL prompt { $$ = $2; } -; +config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL +{ + menu_add_option_allnoconfig_y(); +}; /* choice entry */