summaryrefslogtreecommitdiffstats
path: root/scripts/kconfig
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-12-11 06:01:00 -0500
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-12-21 10:25:52 -0500
commitce2164ab58316e27180034112f97608a764f5b37 (patch)
tree80f0ee899851907326026719a912e3a3d664b7dd /scripts/kconfig
parent3c8f317d4cf15e7a67457cfdd1e63182a34bcb69 (diff)
kconfig: refactor scanning and parsing "option" properties
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 <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r--scripts/kconfig/kconf_id.c3
-rw-r--r--scripts/kconfig/lkc.h9
-rw-r--r--scripts/kconfig/menu.c43
-rw-r--r--scripts/kconfig/zconf.l3
-rw-r--r--scripts/kconfig/zconf.y35
5 files changed, 41 insertions, 52 deletions
diff --git a/scripts/kconfig/kconf_id.c b/scripts/kconfig/kconf_id.c
index ec2c011f9e62..f8b222cc8b87 100644
--- a/scripts/kconfig/kconf_id.c
+++ b/scripts/kconfig/kconf_id.c
@@ -30,9 +30,6 @@ static struct kconf_id kconf_id_array[] = {
30 { "visible", T_VISIBLE, TF_COMMAND }, 30 { "visible", T_VISIBLE, TF_COMMAND },
31 { "option", T_OPTION, TF_COMMAND }, 31 { "option", T_OPTION, TF_COMMAND },
32 { "on", T_ON, TF_PARAM }, 32 { "on", T_ON, TF_PARAM },
33 { "modules", T_OPT_MODULES, TF_OPTION },
34 { "defconfig_list", T_OPT_DEFCONFIG_LIST, TF_OPTION },
35 { "allnoconfig_y", T_OPT_ALLNOCONFIG_Y, TF_OPTION },
36}; 33};
37 34
38#define KCONF_ID_ARRAY_SIZE (sizeof(kconf_id_array)/sizeof(struct kconf_id)) 35#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 b6bbcd1dda2b..5f4880a12246 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -32,7 +32,6 @@ static inline const char *CONFIG_prefix(void)
32 32
33#define TF_COMMAND 0x0001 33#define TF_COMMAND 0x0001
34#define TF_PARAM 0x0002 34#define TF_PARAM 0x0002
35#define TF_OPTION 0x0004
36 35
37enum conf_def_mode { 36enum conf_def_mode {
38 def_default, 37 def_default,
@@ -42,10 +41,6 @@ enum conf_def_mode {
42 def_random 41 def_random
43}; 42};
44 43
45#define T_OPT_MODULES 1
46#define T_OPT_DEFCONFIG_LIST 2
47#define T_OPT_ALLNOCONFIG_Y 4
48
49struct kconf_id { 44struct kconf_id {
50 const char *name; 45 const char *name;
51 int token; 46 int token;
@@ -90,7 +85,9 @@ void menu_add_visibility(struct expr *dep);
90struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); 85struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
91void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); 86void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
92void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); 87void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
93void menu_add_option(int token, char *arg); 88void menu_add_option_modules(void);
89void menu_add_option_defconfig_list(void);
90void menu_add_option_allnoconfig_y(void);
94void menu_finalize(struct menu *parent); 91void menu_finalize(struct menu *parent);
95void menu_set_type(int type); 92void menu_set_type(int type);
96 93
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 4cf15d449c05..7e2b2c938d7b 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)
195 menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); 195 menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep);
196} 196}
197 197
198void menu_add_option(int token, char *arg) 198void menu_add_option_modules(void)
199{ 199{
200 switch (token) { 200 if (modules_sym)
201 case T_OPT_MODULES: 201 zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'",
202 if (modules_sym) 202 current_entry->sym->name, modules_sym->name);
203 zconf_error("symbol '%s' redefines option 'modules'" 203 modules_sym = current_entry->sym;
204 " already defined by symbol '%s'", 204}
205 current_entry->sym->name, 205
206 modules_sym->name 206void menu_add_option_defconfig_list(void)
207 ); 207{
208 modules_sym = current_entry->sym; 208 if (!sym_defconfig_list)
209 break; 209 sym_defconfig_list = current_entry->sym;
210 case T_OPT_DEFCONFIG_LIST: 210 else if (sym_defconfig_list != current_entry->sym)
211 if (!sym_defconfig_list) 211 zconf_error("trying to redefine defconfig symbol");
212 sym_defconfig_list = current_entry->sym; 212 sym_defconfig_list->flags |= SYMBOL_NO_WRITE;
213 else if (sym_defconfig_list != current_entry->sym) 213}
214 zconf_error("trying to redefine defconfig symbol"); 214
215 sym_defconfig_list->flags |= SYMBOL_NO_WRITE; 215void menu_add_option_allnoconfig_y(void)
216 break; 216{
217 case T_OPT_ALLNOCONFIG_Y: 217 current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;
218 current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;
219 break;
220 }
221} 218}
222 219
223static int menu_validate_number(struct symbol *sym, struct symbol *sym2) 220static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index 8e856f9e6da9..30380790bab4 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -140,6 +140,9 @@ n [A-Za-z0-9_-]
140} 140}
141 141
142<PARAM>{ 142<PARAM>{
143 "modules" return T_MODULES;
144 "defconfig_list" return T_DEFCONFIG_LIST;
145 "allnoconfig_y" return T_ALLNOCONFIG_Y;
143 "&&" return T_AND; 146 "&&" return T_AND;
144 "||" return T_OR; 147 "||" return T_OR;
145 "(" return T_OPEN_PAREN; 148 "(" return T_OPEN_PAREN;
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 19fa333e9aa1..e482000bb93e 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -64,18 +64,21 @@ static struct menu *current_menu, *current_entry;
64%token <id>T_IMPLY 64%token <id>T_IMPLY
65%token <id>T_RANGE 65%token <id>T_RANGE
66%token <id>T_VISIBLE 66%token <id>T_VISIBLE
67%token <id>T_OPTION
68%token <id>T_ON 67%token <id>T_ON
69%token <string> T_WORD 68%token <string> T_WORD
70%token <string> T_WORD_QUOTE 69%token <string> T_WORD_QUOTE
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_DEFAULT 73%token T_DEFAULT
74%token T_DEFCONFIG_LIST
74%token T_DEF_BOOL 75%token T_DEF_BOOL
75%token T_DEF_TRISTATE 76%token T_DEF_TRISTATE
76%token T_HEX 77%token T_HEX
77%token T_INT 78%token T_INT
79%token T_MODULES
78%token T_OPEN_PAREN 80%token T_OPEN_PAREN
81%token T_OPTION
79%token T_STRING 82%token T_STRING
80%token T_TRISTATE 83%token T_TRISTATE
81%token T_EOL 84%token T_EOL
@@ -97,7 +100,7 @@ static struct menu *current_menu, *current_entry;
97%type <expr> if_expr 100%type <expr> if_expr
98%type <id> end 101%type <id> end
99%type <menu> if_entry menu_entry choice_entry 102%type <menu> if_entry menu_entry choice_entry
100%type <string> symbol_option_arg word_opt assign_val 103%type <string> word_opt assign_val
101 104
102%destructor { 105%destructor {
103 fprintf(stderr, "%s:%d: missing end statement for this entry\n", 106 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -172,7 +175,6 @@ menuconfig_stmt: menuconfig_entry_start config_option_list
172config_option_list: 175config_option_list:
173 /* empty */ 176 /* empty */
174 | config_option_list config_option 177 | config_option_list config_option
175 | config_option_list symbol_option
176 | config_option_list depends 178 | config_option_list depends
177 | config_option_list help 179 | config_option_list help
178; 180;
@@ -219,27 +221,20 @@ config_option: T_RANGE symbol symbol if_expr T_EOL
219 printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); 221 printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
220}; 222};
221 223
222symbol_option: T_OPTION symbol_option_list T_EOL 224config_option: T_OPTION T_MODULES T_EOL
223; 225{
226 menu_add_option_modules();
227};
224 228
225symbol_option_list: 229config_option: T_OPTION T_DEFCONFIG_LIST T_EOL
226 /* empty */
227 | symbol_option_list T_WORD symbol_option_arg
228{ 230{
229 const struct kconf_id *id = kconf_id_lookup($2, strlen($2)); 231 menu_add_option_defconfig_list();
230 if (id && id->flags & TF_OPTION) {
231 menu_add_option(id->token, $3);
232 free($3);
233 }
234 else
235 zconfprint("warning: ignoring unknown option %s", $2);
236 free($2);
237}; 232};
238 233
239symbol_option_arg: 234config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL
240 /* empty */ { $$ = NULL; } 235{
241 | T_EQUAL prompt { $$ = $2; } 236 menu_add_option_allnoconfig_y();
242; 237};
243 238
244/* choice entry */ 239/* choice entry */
245 240