diff options
Diffstat (limited to 'scripts/kconfig')
-rw-r--r-- | scripts/kconfig/kconf_id.c | 49 | ||||
-rw-r--r-- | scripts/kconfig/lkc.h | 9 | ||||
-rw-r--r-- | scripts/kconfig/zconf.l | 153 | ||||
-rw-r--r-- | scripts/kconfig/zconf.y | 5 |
4 files changed, 69 insertions, 147 deletions
diff --git a/scripts/kconfig/kconf_id.c b/scripts/kconfig/kconf_id.c deleted file mode 100644 index f8b222cc8b87..000000000000 --- a/scripts/kconfig/kconf_id.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | |||
2 | static struct kconf_id kconf_id_array[] = { | ||
3 | { "mainmenu", T_MAINMENU, TF_COMMAND }, | ||
4 | { "menu", T_MENU, TF_COMMAND }, | ||
5 | { "endmenu", T_ENDMENU, TF_COMMAND }, | ||
6 | { "source", T_SOURCE, TF_COMMAND }, | ||
7 | { "choice", T_CHOICE, TF_COMMAND }, | ||
8 | { "endchoice", T_ENDCHOICE, TF_COMMAND }, | ||
9 | { "comment", T_COMMENT, TF_COMMAND }, | ||
10 | { "config", T_CONFIG, TF_COMMAND }, | ||
11 | { "menuconfig", T_MENUCONFIG, TF_COMMAND }, | ||
12 | { "help", T_HELP, TF_COMMAND }, | ||
13 | { "---help---", T_HELP, TF_COMMAND }, | ||
14 | { "if", T_IF, TF_COMMAND|TF_PARAM }, | ||
15 | { "endif", T_ENDIF, TF_COMMAND }, | ||
16 | { "depends", T_DEPENDS, TF_COMMAND }, | ||
17 | { "optional", T_OPTIONAL, TF_COMMAND }, | ||
18 | { "default", T_DEFAULT, TF_COMMAND }, | ||
19 | { "def_bool", T_DEF_BOOL, TF_COMMAND }, | ||
20 | { "def_tristate", T_DEF_TRISTATE, TF_COMMAND }, | ||
21 | { "prompt", T_PROMPT, TF_COMMAND }, | ||
22 | { "bool", T_BOOL, TF_COMMAND }, | ||
23 | { "tristate", T_TRISTATE, TF_COMMAND }, | ||
24 | { "int", T_INT, TF_COMMAND }, | ||
25 | { "hex", T_HEX, TF_COMMAND }, | ||
26 | { "string", T_STRING, TF_COMMAND }, | ||
27 | { "select", T_SELECT, TF_COMMAND }, | ||
28 | { "imply", T_IMPLY, TF_COMMAND }, | ||
29 | { "range", T_RANGE, TF_COMMAND }, | ||
30 | { "visible", T_VISIBLE, TF_COMMAND }, | ||
31 | { "option", T_OPTION, TF_COMMAND }, | ||
32 | { "on", T_ON, TF_PARAM }, | ||
33 | }; | ||
34 | |||
35 | #define KCONF_ID_ARRAY_SIZE (sizeof(kconf_id_array)/sizeof(struct kconf_id)) | ||
36 | |||
37 | static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len) | ||
38 | { | ||
39 | int i; | ||
40 | |||
41 | for (i = 0; i < KCONF_ID_ARRAY_SIZE; i++) { | ||
42 | struct kconf_id *id = kconf_id_array+i; | ||
43 | int l = strlen(id->name); | ||
44 | |||
45 | if (len == l && !memcmp(str, id->name, len)) | ||
46 | return id; | ||
47 | } | ||
48 | return NULL; | ||
49 | } | ||
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 5f4880a12246..ff6b3e414788 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -30,9 +30,6 @@ static inline const char *CONFIG_prefix(void) | |||
30 | #undef CONFIG_ | 30 | #undef CONFIG_ |
31 | #define CONFIG_ CONFIG_prefix() | 31 | #define CONFIG_ CONFIG_prefix() |
32 | 32 | ||
33 | #define TF_COMMAND 0x0001 | ||
34 | #define TF_PARAM 0x0002 | ||
35 | |||
36 | enum conf_def_mode { | 33 | enum conf_def_mode { |
37 | def_default, | 34 | def_default, |
38 | def_yes, | 35 | def_yes, |
@@ -41,12 +38,6 @@ enum conf_def_mode { | |||
41 | def_random | 38 | def_random |
42 | }; | 39 | }; |
43 | 40 | ||
44 | struct kconf_id { | ||
45 | const char *name; | ||
46 | int token; | ||
47 | unsigned int flags; | ||
48 | }; | ||
49 | |||
50 | extern int yylineno; | 41 | extern int yylineno; |
51 | void zconfdump(FILE *out); | 42 | void zconfdump(FILE *out); |
52 | void zconf_starthelp(void); | 43 | void zconf_starthelp(void); |
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 9b083a176fb4..d78efad64f51 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -1,6 +1,6 @@ | |||
1 | %option nostdinit noyywrap never-interactive full ecs | 1 | %option nostdinit noyywrap never-interactive full ecs |
2 | %option 8bit nodefault yylineno | 2 | %option 8bit nodefault yylineno |
3 | %x COMMAND HELP STRING PARAM ASSIGN_VAL | 3 | %x ASSIGN_VAL HELP STRING |
4 | %{ | 4 | %{ |
5 | /* | 5 | /* |
6 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 6 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
@@ -87,45 +87,73 @@ n [A-Za-z0-9_-] | |||
87 | int str = 0; | 87 | int str = 0; |
88 | int ts, i; | 88 | int ts, i; |
89 | 89 | ||
90 | [ \t]*#.*\n | | 90 | #.* /* ignore comment */ |
91 | [ \t]*\n { | 91 | [ \t]* /* whitespaces */ |
92 | return T_EOL; | 92 | \\\n /* escaped new line */ |
93 | } | 93 | \n return T_EOL; |
94 | [ \t]*#.* | 94 | "allnoconfig_y" return T_ALLNOCONFIG_Y; |
95 | . { | 95 | "bool" return T_BOOL; |
96 | unput(yytext[0]); | 96 | "choice" return T_CHOICE; |
97 | BEGIN(COMMAND); | 97 | "comment" return T_COMMENT; |
98 | } | 98 | "config" return T_CONFIG; |
99 | 99 | "def_bool" return T_DEF_BOOL; | |
100 | 100 | "def_tristate" return T_DEF_TRISTATE; | |
101 | <COMMAND>{ | 101 | "default" return T_DEFAULT; |
102 | {n}+ { | 102 | "defconfig_list" return T_DEFCONFIG_LIST; |
103 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); | 103 | "depends" return T_DEPENDS; |
104 | if (id && id->flags & TF_COMMAND) { | 104 | "endchoice" return T_ENDCHOICE; |
105 | BEGIN(PARAM); | 105 | "endif" return T_ENDIF; |
106 | return id->token; | 106 | "endmenu" return T_ENDMENU; |
107 | } | 107 | "help"|"---help---" return T_HELP; |
108 | alloc_string(yytext, yyleng); | 108 | "hex" return T_HEX; |
109 | yylval.string = text; | 109 | "if" return T_IF; |
110 | return T_WORD; | 110 | "imply" return T_IMPLY; |
111 | } | 111 | "int" return T_INT; |
112 | ({n}|$)+ { | 112 | "mainmenu" return T_MAINMENU; |
113 | /* this token includes at least one '$' */ | 113 | "menu" return T_MENU; |
114 | yylval.string = expand_token(yytext, yyleng); | 114 | "menuconfig" return T_MENUCONFIG; |
115 | if (strlen(yylval.string)) | 115 | "modules" return T_MODULES; |
116 | return T_WORD; | 116 | "on" return T_ON; |
117 | free(yylval.string); | 117 | "option" return T_OPTION; |
118 | } | 118 | "optional" return T_OPTIONAL; |
119 | "=" return T_EQUAL; | 119 | "prompt" return T_PROMPT; |
120 | ":=" return T_COLON_EQUAL; | 120 | "range" return T_RANGE; |
121 | "+=" return T_PLUS_EQUAL; | 121 | "select" return T_SELECT; |
122 | [[:blank:]]+ | 122 | "source" return T_SOURCE; |
123 | . warn_ignored_character(*yytext); | 123 | "string" return T_STRING; |
124 | \n { | 124 | "tristate" return T_TRISTATE; |
125 | BEGIN(INITIAL); | 125 | "visible" return T_VISIBLE; |
126 | return T_EOL; | 126 | "||" return T_OR; |
127 | } | 127 | "&&" return T_AND; |
128 | } | 128 | "=" return T_EQUAL; |
129 | "!=" return T_UNEQUAL; | ||
130 | "<" return T_LESS; | ||
131 | "<=" return T_LESS_EQUAL; | ||
132 | ">" return T_GREATER; | ||
133 | ">=" return T_GREATER_EQUAL; | ||
134 | "!" return T_NOT; | ||
135 | "(" return T_OPEN_PAREN; | ||
136 | ")" return T_CLOSE_PAREN; | ||
137 | ":=" return T_COLON_EQUAL; | ||
138 | "+=" return T_PLUS_EQUAL; | ||
139 | \"|\' { | ||
140 | str = yytext[0]; | ||
141 | new_string(); | ||
142 | BEGIN(STRING); | ||
143 | } | ||
144 | {n}+ { | ||
145 | alloc_string(yytext, yyleng); | ||
146 | yylval.string = text; | ||
147 | return T_WORD; | ||
148 | } | ||
149 | ({n}|$)+ { | ||
150 | /* this token includes at least one '$' */ | ||
151 | yylval.string = expand_token(yytext, yyleng); | ||
152 | if (strlen(yylval.string)) | ||
153 | return T_WORD; | ||
154 | free(yylval.string); | ||
155 | } | ||
156 | . warn_ignored_character(*yytext); | ||
129 | 157 | ||
130 | <ASSIGN_VAL>{ | 158 | <ASSIGN_VAL>{ |
131 | [^[:blank:]\n]+.* { | 159 | [^[:blank:]\n]+.* { |
@@ -137,49 +165,6 @@ n [A-Za-z0-9_-] | |||
137 | . | 165 | . |
138 | } | 166 | } |
139 | 167 | ||
140 | <PARAM>{ | ||
141 | "modules" return T_MODULES; | ||
142 | "defconfig_list" return T_DEFCONFIG_LIST; | ||
143 | "allnoconfig_y" return T_ALLNOCONFIG_Y; | ||
144 | "&&" return T_AND; | ||
145 | "||" return T_OR; | ||
146 | "(" return T_OPEN_PAREN; | ||
147 | ")" return T_CLOSE_PAREN; | ||
148 | "!" return T_NOT; | ||
149 | "=" return T_EQUAL; | ||
150 | "!=" return T_UNEQUAL; | ||
151 | "<=" return T_LESS_EQUAL; | ||
152 | ">=" return T_GREATER_EQUAL; | ||
153 | "<" return T_LESS; | ||
154 | ">" return T_GREATER; | ||
155 | \"|\' { | ||
156 | str = yytext[0]; | ||
157 | new_string(); | ||
158 | BEGIN(STRING); | ||
159 | } | ||
160 | \n BEGIN(INITIAL); return T_EOL; | ||
161 | {n}+ { | ||
162 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); | ||
163 | if (id && id->flags & TF_PARAM) { | ||
164 | return id->token; | ||
165 | } | ||
166 | alloc_string(yytext, yyleng); | ||
167 | yylval.string = text; | ||
168 | return T_WORD; | ||
169 | } | ||
170 | ({n}|$)+ { | ||
171 | /* this token includes at least one '$' */ | ||
172 | yylval.string = expand_token(yytext, yyleng); | ||
173 | if (strlen(yylval.string)) | ||
174 | return T_WORD; | ||
175 | free(yylval.string); | ||
176 | } | ||
177 | #.* /* comment */ | ||
178 | \\\n ; | ||
179 | [[:blank:]]+ | ||
180 | . warn_ignored_character(*yytext); | ||
181 | } | ||
182 | |||
183 | <STRING>{ | 168 | <STRING>{ |
184 | "$".* append_expanded_string(yytext); | 169 | "$".* append_expanded_string(yytext); |
185 | [^$'"\\\n]+ { | 170 | [^$'"\\\n]+ { |
@@ -190,7 +175,7 @@ n [A-Za-z0-9_-] | |||
190 | } | 175 | } |
191 | \'|\" { | 176 | \'|\" { |
192 | if (str == yytext[0]) { | 177 | if (str == yytext[0]) { |
193 | BEGIN(PARAM); | 178 | BEGIN(INITIAL); |
194 | yylval.string = text; | 179 | yylval.string = text; |
195 | return T_WORD_QUOTE; | 180 | return T_WORD_QUOTE; |
196 | } else | 181 | } else |
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 3a3ada6f0729..6fb80f210dfb 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y | |||
@@ -110,11 +110,6 @@ static struct menu *current_menu, *current_entry; | |||
110 | menu_end_menu(); | 110 | menu_end_menu(); |
111 | } if_entry menu_entry choice_entry | 111 | } if_entry menu_entry choice_entry |
112 | 112 | ||
113 | %{ | ||
114 | /* Include kconf_id.c here so it can see the token constants. */ | ||
115 | #include "kconf_id.c" | ||
116 | %} | ||
117 | |||
118 | %% | 113 | %% |
119 | input: mainmenu_stmt stmt_list | stmt_list; | 114 | input: mainmenu_stmt stmt_list | stmt_list; |
120 | 115 | ||