-rw-r--r-- | scripts/kconfig/zconf.l | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 1471630..55517b2 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -87,38 +87,45 @@ n [A-Za-z0-9_] | |||
87 | } | 87 | } |
88 | 88 | ||
89 | 89 | ||
90 | <COMMAND>{ | 90 | <COMMAND>{ |
91 | "mainmenu" BEGIN(PARAM); return T_MAINMENU; | 91 | "mainmenu" BEGIN(PARAM); return T_MAINMENU; |
92 | "menu" BEGIN(PARAM); return T_MENU; | 92 | "menu" BEGIN(PARAM); return T_MENU; |
93 | "endmenu" BEGIN(PARAM); return T_ENDMENU; | 93 | "endmenu" BEGIN(PARAM); return T_ENDMENU; |
94 | "source" BEGIN(PARAM); return T_SOURCE; | 94 | "source" BEGIN(PARAM); return T_SOURCE; |
95 | "choice" BEGIN(PARAM); return T_CHOICE; | 95 | "choice" BEGIN(PARAM); return T_CHOICE; |
96 | "endchoice" BEGIN(PARAM); return T_ENDCHOICE; | 96 | "endchoice" BEGIN(PARAM); return T_ENDCHOICE; |
97 | "comment" BEGIN(PARAM); return T_COMMENT; | 97 | "comment" BEGIN(PARAM); return T_COMMENT; |
98 | "config" BEGIN(PARAM); return T_CONFIG; | 98 | "config" BEGIN(PARAM); return T_CONFIG; |
99 | "menuconfig" BEGIN(PARAM); return T_MENUCONFIG; | ||
99 | "help" BEGIN(PARAM); return T_HELP; | 100 | "help" BEGIN(PARAM); return T_HELP; |
100 | "if" BEGIN(PARAM); return T_IF; | 101 | "if" BEGIN(PARAM); return T_IF; |
101 | "endif" BEGIN(PARAM); return T_ENDIF; | 102 | "endif" BEGIN(PARAM); return T_ENDIF; |
102 | "depends" BEGIN(PARAM); return T_DEPENDS; | 103 | "depends" BEGIN(PARAM); return T_DEPENDS; |
103 | "requires" BEGIN(PARAM); return T_REQUIRES; | 104 | "requires" BEGIN(PARAM); return T_REQUIRES; |
104 | "optional" BEGIN(PARAM); return T_OPTIONAL; | 105 | "optional" BEGIN(PARAM); return T_OPTIONAL; |
105 | "default" BEGIN(PARAM); return T_DEFAULT; | 106 | "default" BEGIN(PARAM); return T_DEFAULT; |
106 | "prompt" BEGIN(PARAM); return T_PROMPT; | 107 | "prompt" BEGIN(PARAM); return T_PROMPT; |
107 | "tristate" BEGIN(PARAM); return T_TRISTATE; | 108 | "tristate" BEGIN(PARAM); return T_TRISTATE; |
109 | "def_tristate" BEGIN(PARAM); return T_DEF_TRISTATE; | ||
108 | "bool" BEGIN(PARAM); return T_BOOLEAN; | 110 | "bool" BEGIN(PARAM); return T_BOOLEAN; |
109 | "boolean" BEGIN(PARAM); return T_BOOLEAN; | 111 | "boolean" BEGIN(PARAM); return T_BOOLEAN; |
112 | "def_bool" BEGIN(PARAM); return T_DEF_BOOLEAN; | ||
113 | "def_boolean" BEGIN(PARAM); return T_DEF_BOOLEAN; | ||
110 | "int" BEGIN(PARAM); return T_INT; | 114 | "int" BEGIN(PARAM); return T_INT; |
111 | "hex" BEGIN(PARAM); return T_HEX; | 115 | "hex" BEGIN(PARAM); return T_HEX; |
112 | "string" BEGIN(PARAM); return T_STRING; | 116 | "string" BEGIN(PARAM); return T_STRING; |
117 | "select" BEGIN(PARAM); return T_SELECT; | ||
118 | "enable" BEGIN(PARAM); return T_SELECT; | ||
119 | "range" BEGIN(PARAM); return T_RANGE; | ||
113 | {n}+{ | 120 | {n}+{ |
114 | alloc_string(yytext, yyleng); | 121 | alloc_string(yytext, yyleng); |
115 | zconflval.string = text; | 122 | zconflval.string = text; |
116 | return T_WORD; | 123 | return T_WORD; |
117 | } | 124 | } |
118 | . | 125 | . |
119 | \ncurrent_file->lineno++; BEGIN(INITIAL); | 126 | \ncurrent_file->lineno++; BEGIN(INITIAL); |
120 | } | 127 | } |
121 | 128 | ||
122 | <PARAM>{ | 129 | <PARAM>{ |
123 | "&&"return T_AND; | 130 | "&&"return T_AND; |
124 | "||"return T_OR; | 131 | "||"return T_OR; |
@@ -132,53 +139,54 @@ n [A-Za-z0-9_] | |||
132 | \"|\'{ | 139 | \"|\'{ |
133 | str = yytext[0]; | 140 | str = yytext[0]; |
134 | new_string(); | 141 | new_string(); |
135 | BEGIN(STRING); | 142 | BEGIN(STRING); |
136 | } | 143 | } |
137 | \nBEGIN(INITIAL); current_file->lineno++; return T_EOL; | 144 | \nBEGIN(INITIAL); current_file->lineno++; return T_EOL; |
138 | ---/* ignore */ | 145 | ---/* ignore */ |
139 | ({n}|[-/.])+{ | 146 | ({n}|[-/.])+{ |
140 | alloc_string(yytext, yyleng); | 147 | alloc_string(yytext, yyleng); |
141 | zconflval.string = text; | 148 | zconflval.string = text; |
142 | return T_WORD; | 149 | return T_WORD; |
143 | } | 150 | } |
151 | #.*/* comment */ | ||
144 | \\\ncurrent_file->lineno++; | 152 | \\\ncurrent_file->lineno++; |
145 | . | 153 | . |
146 | <<EOF>> { | 154 | <<EOF>> { |
147 | BEGIN(INITIAL); | 155 | BEGIN(INITIAL); |
148 | } | 156 | } |
149 | } | 157 | } |
150 | 158 | ||
151 | <STRING>{ | 159 | <STRING>{ |
152 | [^'"\\\n]+/\n{ | 160 | [^'"\\\n]+/\n{ |
153 | append_string(yytext, yyleng); | 161 | append_string(yytext, yyleng); |
154 | zconflval.string = text; | 162 | zconflval.string = text; |
155 | return T_STRING; | 163 | return T_WORD_QUOTE; |
156 | } | 164 | } |
157 | [^'"\\\n]+{ | 165 | [^'"\\\n]+{ |
158 | append_string(yytext, yyleng); | 166 | append_string(yytext, yyleng); |
159 | } | 167 | } |
160 | \\.?/\n{ | 168 | \\.?/\n{ |
161 | append_string(yytext + 1, yyleng - 1); | 169 | append_string(yytext + 1, yyleng - 1); |
162 | zconflval.string = text; | 170 | zconflval.string = text; |
163 | return T_STRING; | 171 | return T_WORD_QUOTE; |
164 | } | 172 | } |
165 | \\.?{ | 173 | \\.?{ |
166 | append_string(yytext + 1, yyleng - 1); | 174 | append_string(yytext + 1, yyleng - 1); |
167 | } | 175 | } |
168 | \'|\"{ | 176 | \'|\"{ |
169 | if (str == yytext[0]) { | 177 | if (str == yytext[0]) { |
170 | BEGIN(PARAM); | 178 | BEGIN(PARAM); |
171 | zconflval.string = text; | 179 | zconflval.string = text; |
172 | return T_STRING; | 180 | return T_WORD_QUOTE; |
173 | } else | 181 | } else |
174 | append_string(yytext, 1); | 182 | append_string(yytext, 1); |
175 | } | 183 | } |
176 | \n{ | 184 | \n{ |
177 | printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); | 185 | printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); |
178 | current_file->lineno++; | 186 | current_file->lineno++; |
179 | BEGIN(INITIAL); | 187 | BEGIN(INITIAL); |
180 | return T_EOL; | 188 | return T_EOL; |
181 | } | 189 | } |
182 | <<EOF>>{ | 190 | <<EOF>>{ |
183 | BEGIN(INITIAL); | 191 | BEGIN(INITIAL); |
184 | } | 192 | } |
@@ -197,27 +205,26 @@ n [A-Za-z0-9_] | |||
197 | if (first_ts) { | 205 | if (first_ts) { |
198 | if (ts < first_ts) { | 206 | if (ts < first_ts) { |
199 | zconf_endhelp(); | 207 | zconf_endhelp(); |
200 | return T_HELPTEXT; | 208 | return T_HELPTEXT; |
201 | } | 209 | } |
202 | ts -= first_ts; | 210 | ts -= first_ts; |
203 | while (ts > 8) { | 211 | while (ts > 8) { |
204 | append_string(" ", 8); | 212 | append_string(" ", 8); |
205 | ts -= 8; | 213 | ts -= 8; |
206 | } | 214 | } |
207 | append_string(" ", ts); | 215 | append_string(" ", ts); |
208 | } | 216 | } |
209 | |||
210 | } | 217 | } |
211 | \n/[^ \t\n] { | 218 | [ \t]*\n/[^ \t\n] { |
212 | current_file->lineno++; | 219 | current_file->lineno++; |
213 | zconf_endhelp(); | 220 | zconf_endhelp(); |
214 | return T_HELPTEXT; | 221 | return T_HELPTEXT; |
215 | } | 222 | } |
216 | [ \t]*\n{ | 223 | [ \t]*\n{ |
217 | current_file->lineno++; | 224 | current_file->lineno++; |
218 | append_string("\n", 1); | 225 | append_string("\n", 1); |
219 | } | 226 | } |
220 | [^ \t\n].* { | 227 | [^ \t\n].* { |
221 | append_string(yytext, yyleng); | 228 | append_string(yytext, yyleng); |
222 | if (!first_ts) | 229 | if (!first_ts) |
223 | first_ts = last_ts; | 230 | first_ts = last_ts; |
@@ -239,29 +246,29 @@ n [A-Za-z0-9_] | |||
239 | 246 | ||
240 | %% | 247 | %% |
241 | void zconf_starthelp(void) | 248 | void zconf_starthelp(void) |
242 | { | 249 | { |
243 | new_string(); | 250 | new_string(); |
244 | last_ts = first_ts = 0; | 251 | last_ts = first_ts = 0; |
245 | BEGIN(HELP); | 252 | BEGIN(HELP); |
246 | } | 253 | } |
247 | 254 | ||
248 | static void zconf_endhelp(void) | 255 | static void zconf_endhelp(void) |
249 | { | 256 | { |
250 | zconflval.string = text; | 257 | zconflval.string = text; |
251 | BEGIN(INITIAL); | 258 | BEGIN(INITIAL); |
252 | } | 259 | } |
253 | 260 | ||
254 | 261 | ||
255 | /* | 262 | /* |
256 | * Try to open specified file with following names: | 263 | * Try to open specified file with following names: |
257 | * ./name | 264 | * ./name |
258 | * $(srctree)/name | 265 | * $(srctree)/name |
259 | * The latter is used when srctree is separate from objtree | 266 | * The latter is used when srctree is separate from objtree |
260 | * when compiling the kernel. | 267 | * when compiling the kernel. |
261 | * Return NULL if file is not found. | 268 | * Return NULL if file is not found. |
262 | */ | 269 | */ |
263 | FILE *zconf_fopen(const char *name) | 270 | FILE *zconf_fopen(const char *name) |
264 | { | 271 | { |
265 | char *env, fullname[PATH_MAX+1]; | 272 | char *env, fullname[PATH_MAX+1]; |
266 | FILE *f; | 273 | FILE *f; |
267 | 274 | ||
@@ -336,24 +343,24 @@ static struct buffer *zconf_endfile(void) | |||
336 | yy_delete_buffer(YY_CURRENT_BUFFER); | 343 | yy_delete_buffer(YY_CURRENT_BUFFER); |
337 | yy_switch_to_buffer(parent->state); | 344 | yy_switch_to_buffer(parent->state); |
338 | } | 345 | } |
339 | free(current_buf); | 346 | free(current_buf); |
340 | current_buf = parent; | 347 | current_buf = parent; |
341 | 348 | ||
342 | return parent; | 349 | return parent; |
343 | } | 350 | } |
344 | 351 | ||
345 | int zconf_lineno(void) | 352 | int zconf_lineno(void) |
346 | { | 353 | { |
347 | if (current_buf) | 354 | if (current_buf) |
348 | return current_file->lineno; | 355 | return current_file->lineno - 1; |
349 | else | 356 | else |
350 | return 0; | 357 | return 0; |
351 | } | 358 | } |
352 | 359 | ||
353 | char *zconf_curname(void) | 360 | char *zconf_curname(void) |
354 | { | 361 | { |
355 | if (current_buf) | 362 | if (current_buf) |
356 | return current_file->name; | 363 | return current_file->name; |
357 | else | 364 | else |
358 | return "<none>"; | 365 | return "<none>"; |
359 | } | 366 | } |