diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-12-11 06:01:01 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-12-21 10:25:52 -0500 |
commit | c3d228713b10e6dd1bd44853168cec8e23ae7e0f (patch) | |
tree | 199226be6fababdd0bc090b60149eca39f3604c4 /scripts/kconfig | |
parent | ce2164ab58316e27180034112f97608a764f5b37 (diff) |
kconfig: use specific tokens instead of T_ASSIGN for assignments
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, the same token T_EQUAL is used for assignment and comparison.
The parser can still distinguish them from the context.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r-- | scripts/kconfig/zconf.l | 6 | ||||
-rw-r--r-- | scripts/kconfig/zconf.y | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 30380790bab4..b1a71f612c11 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -118,9 +118,9 @@ n [A-Za-z0-9_-] | |||
118 | return T_VARIABLE; | 118 | return T_VARIABLE; |
119 | free(yylval.string); | 119 | free(yylval.string); |
120 | } | 120 | } |
121 | "=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_RECURSIVE; return T_ASSIGN; } | 121 | "=" { BEGIN(ASSIGN_VAL); return T_EQUAL; } |
122 | ":=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_SIMPLE; return T_ASSIGN; } | 122 | ":=" { BEGIN(ASSIGN_VAL); return T_COLON_EQUAL; } |
123 | "+=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_APPEND; return T_ASSIGN; } | 123 | "+=" { BEGIN(ASSIGN_VAL); return T_PLUS_EQUAL; } |
124 | [[:blank:]]+ | 124 | [[:blank:]]+ |
125 | . warn_ignored_character(*yytext); | 125 | . warn_ignored_character(*yytext); |
126 | \n { | 126 | \n { |
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index e482000bb93e..3b7ebd363e7e 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y | |||
@@ -70,6 +70,7 @@ static struct menu *current_menu, *current_entry; | |||
70 | %token T_ALLNOCONFIG_Y | 70 | %token T_ALLNOCONFIG_Y |
71 | %token T_BOOL | 71 | %token T_BOOL |
72 | %token T_CLOSE_PAREN | 72 | %token T_CLOSE_PAREN |
73 | %token T_COLON_EQUAL | ||
73 | %token T_DEFAULT | 74 | %token T_DEFAULT |
74 | %token T_DEFCONFIG_LIST | 75 | %token T_DEFCONFIG_LIST |
75 | %token T_DEF_BOOL | 76 | %token T_DEF_BOOL |
@@ -79,11 +80,11 @@ static struct menu *current_menu, *current_entry; | |||
79 | %token T_MODULES | 80 | %token T_MODULES |
80 | %token T_OPEN_PAREN | 81 | %token T_OPEN_PAREN |
81 | %token T_OPTION | 82 | %token T_OPTION |
83 | %token T_PLUS_EQUAL | ||
82 | %token T_STRING | 84 | %token T_STRING |
83 | %token T_TRISTATE | 85 | %token T_TRISTATE |
84 | %token T_EOL | 86 | %token T_EOL |
85 | %token <string> T_VARIABLE | 87 | %token <string> T_VARIABLE |
86 | %token <flavor> T_ASSIGN | ||
87 | %token <string> T_ASSIGN_VAL | 88 | %token <string> T_ASSIGN_VAL |
88 | 89 | ||
89 | %left T_OR | 90 | %left T_OR |
@@ -101,6 +102,7 @@ static struct menu *current_menu, *current_entry; | |||
101 | %type <id> end | 102 | %type <id> end |
102 | %type <menu> if_entry menu_entry choice_entry | 103 | %type <menu> if_entry menu_entry choice_entry |
103 | %type <string> word_opt assign_val | 104 | %type <string> word_opt assign_val |
105 | %type <flavor> assign_op | ||
104 | 106 | ||
105 | %destructor { | 107 | %destructor { |
106 | fprintf(stderr, "%s:%d: missing end statement for this entry\n", | 108 | fprintf(stderr, "%s:%d: missing end statement for this entry\n", |
@@ -478,7 +480,13 @@ word_opt: /* empty */ { $$ = NULL; } | |||
478 | 480 | ||
479 | /* assignment statement */ | 481 | /* assignment statement */ |
480 | 482 | ||
481 | assignment_stmt: T_VARIABLE T_ASSIGN assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); } | 483 | assignment_stmt: T_VARIABLE assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); } |
484 | |||
485 | assign_op: | ||
486 | T_EQUAL { $$ = VAR_RECURSIVE; } | ||
487 | | T_COLON_EQUAL { $$ = VAR_SIMPLE; } | ||
488 | | T_PLUS_EQUAL { $$ = VAR_APPEND; } | ||
489 | ; | ||
482 | 490 | ||
483 | assign_val: | 491 | assign_val: |
484 | /* empty */ { $$ = xstrdup(""); }; | 492 | /* empty */ { $$ = xstrdup(""); }; |