From patchwork Tue Dec 11 11:01:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 153436 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp476304ljp; Tue, 11 Dec 2018 03:03:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/VNdY2qaCtHraq+kw0w144YK6CvbDdnztrrQtbpxw4nP5IzIxvhMfC3pk9IoPgaJ5Tbg015 X-Received: by 2002:a63:c42:: with SMTP id 2mr14235524pgm.372.1544526196425; Tue, 11 Dec 2018 03:03:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544526196; cv=none; d=google.com; s=arc-20160816; b=t7z08v3lPOH/0XhBFeDlevsmTm3MYTSFGIU0+Thfao7AoSqpMdvEPmxEr7bUx60Jfz Sd0II/7XHvt6dBvHjQftYGNxlr43Ru6ZWts/VJcU/+Bqmii8v+MRqJtVVO9DdfsZ/tmf VADxcYgG5Hs7iHTQ9XJFNJxmPOAmGUEWSALdGH+oylDvI8p57jGCgQOIvrIdMSUyBO7r /V9CYlvHpRHScO7smz6mj1T5IvsAmGLoLs5BbvuNKvWVJxr9pwKZsNW0qc3Jki2CHtra ZuBStoZxDIw8iLRYdFyYzKVTlLE4cDuCynF5zL9m9e16JP0VYDa5CxGu84B/MSpIc124 SVTQ== 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=w/qYlVHaXWWOa9cxgI46RT+MZV4dG4xlFL58RSeeBfA=; b=JyLMsh6buwycf97VteQAUYew0zv1LnKGrk5HdsbrlRB/ek51UEBXqLdY7NedLNm3pF wo3puot0ouGlkmMlobBYeQ96aqvyq0cNauKdr3db1c7phe7e0/z9uflcbJoMW93LW1tE ZOhiFGY41WcAHLcUNYdduLaUtYp/9AFTJmuGOQTc7zzW6rcFxIuQUzW9cIxQR59tJoNa xa5uS4TuiZErMvg5Ld7xoRwYy+cVYixQYfX/qNLUatL6eXAIVxoW6EDm9F5196gUzkxW vReTlYMuN8ZqwC/qIBl0CLly/uVsNUTxHrvR6ufLA/oII2pt9WQUQskdvEnieyns1BX6 4fnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=AOvmGtDG; 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 10si11652776pgk.101.2018.12.11.03.03.16; Tue, 11 Dec 2018 03:03:16 -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=AOvmGtDG; 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 S1726274AbeLKLDN (ORCPT + 31 others); Tue, 11 Dec 2018 06:03:13 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:36704 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726588AbeLKLBn (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 wBBB1C5t017210; Tue, 11 Dec 2018 20:01:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com wBBB1C5t017210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544526085; bh=w/qYlVHaXWWOa9cxgI46RT+MZV4dG4xlFL58RSeeBfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AOvmGtDGss4NmM5N9cdOCLCqVoW5tbiBQAk95isqDaBaxmdJzU/dOWTpZAeDKHOr7 9EZCwu6vK88iJVjI2Ou0NzN/771Lo0mUvDET6Zf8ch7r1fFt7WdF2VkbZXDcTDFx6m GELp4kONZXTHIO/AlX2FO07CHMlI1GBaBYEzLiBr4S97vd6w8IUK2ENNtWhhO3/N3G AvL0rMsWh4R+dZokNWu3UER3zZIpDDmWMmXEKkbyZ/6ge/edMzSwIcVsYB2nX7yWVy arhyOXSHeGG8PsIyw3md1jS42FyTnbZtiBtCZLDjSkPu2g19KjOSqey8X802PHKcLC FpfjWq+mmQ24A== 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 18/27] kconfig: use specific tokens instead of T_ASSIGN for assignments Date: Tue, 11 Dec 2018 20:01:01 +0900 Message-Id: <1544526070-16690-19-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 Currently, the lexer returns T_ASSIGN for all of =, :=, and += associating yylval with the flavor. I want to make the generated lexer as simple as possible. So, the lexer should convert keywords to tokens without thinking about the meaning. = -> T_EQUAL := -> T_COLON_EQUAL += -> T_PLUS_EQUAL Unfortunately, Kconfig uses = instead of == for the equal operator. So, both assignment and comparison use T_EQUAL. The parser can still distinguish them from the context. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 6 +++--- scripts/kconfig/zconf.y | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 0265502..981b5f8 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -125,9 +125,9 @@ n [A-Za-z0-9_-] return T_VARIABLE; free(yylval.string); } - "=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_RECURSIVE; return T_ASSIGN; } - ":=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_SIMPLE; return T_ASSIGN; } - "+=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_APPEND; return T_ASSIGN; } + "=" { BEGIN(ASSIGN_VAL); return T_EQUAL; } + ":=" { BEGIN(ASSIGN_VAL); return T_COLON_EQUAL; } + "+=" { BEGIN(ASSIGN_VAL); return T_PLUS_EQUAL; } [[:blank:]]+ . warn_ignored_character(*yytext); \n { diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 8db9189..97f86e2 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -70,6 +70,7 @@ static struct menu *current_menu, *current_entry; %token T_ALLNOCONFIG_Y %token T_BOOL %token T_CLOSE_PAREN +%token T_COLON_EQUAL %token T_DEFAULT %token T_DEFCONFIG_LIST %token T_DEF_BOOL @@ -79,11 +80,11 @@ static struct menu *current_menu, *current_entry; %token T_MODULES %token T_OPEN_PAREN %token T_OPTION +%token T_PLUS_EQUAL %token T_STRING %token T_TRISTATE %token T_EOL %token T_VARIABLE -%token T_ASSIGN %token T_ASSIGN_VAL %left T_OR @@ -101,6 +102,7 @@ static struct menu *current_menu, *current_entry; %type end %type if_entry menu_entry choice_entry %type word_opt assign_val +%type assign_op %destructor { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -478,7 +480,13 @@ word_opt: /* empty */ { $$ = NULL; } /* assignment statement */ -assignment_stmt: T_VARIABLE T_ASSIGN assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); } +assignment_stmt: T_VARIABLE assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); } + +assign_op: + T_EQUAL { $$ = VAR_RECURSIVE; } + | T_COLON_EQUAL { $$ = VAR_SIMPLE; } + | T_PLUS_EQUAL { $$ = VAR_APPEND; } +; assign_val: /* empty */ { $$ = xstrdup(""); };