Sun Mar 11 00:14:20 2012 UTC ()
Comments.


(dholland)
diff -r1.24 -r1.25 src/usr.bin/config/gram.y

cvs diff -r1.24 -r1.25 src/usr.bin/config/gram.y (expand / switch to unified diff)

--- src/usr.bin/config/gram.y 2010/04/30 20:47:18 1.24
+++ src/usr.bin/config/gram.y 2012/03/11 00:14:20 1.25
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1%{ 1%{
2/* $NetBSD: gram.y,v 1.24 2010/04/30 20:47:18 pooka Exp $ */ 2/* $NetBSD: gram.y,v 1.25 2012/03/11 00:14:20 dholland Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1992, 1993 5 * Copyright (c) 1992, 1993
6 * The Regents of the University of California. All rights reserved. 6 * The Regents of the University of California. All rights reserved.
7 * 7 *
8 * This software was developed by the Computer Systems Engineering group 8 * This software was developed by the Computer Systems Engineering group
9 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 9 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
10 * contributed to Berkeley. 10 * contributed to Berkeley.
11 * 11 *
12 * All advertising materials mentioning features or use of this software 12 * All advertising materials mentioning features or use of this software
13 * must display the following acknowledgement: 13 * must display the following acknowledgement:
14 * This product includes software developed by the University of 14 * This product includes software developed by the University of
15 * California, Lawrence Berkeley Laboratories. 15 * California, Lawrence Berkeley Laboratories.
@@ -153,155 +153,215 @@ static struct nvlist *mk_ns(const char * @@ -153,155 +153,215 @@ static struct nvlist *mk_ns(const char *
153%type <list> defopts 153%type <list> defopts
154%type <str> optdep 154%type <str> optdep
155%type <list> optdeps 155%type <list> optdeps
156%type <list> defoptdeps 156%type <list> defoptdeps
157%type <str> optfile_opt 157%type <str> optfile_opt
158%type <list> subarches_opt subarches 158%type <list> subarches_opt subarches
159%type <str> filename stringvalue locname mkvarname 159%type <str> filename stringvalue locname mkvarname
160%type <val> device_major_block device_major_char 160%type <val> device_major_block device_major_char
161%type <list> devnodes devnodetype devnodeflags devnode_dims 161%type <list> devnodes devnodetype devnodeflags devnode_dims
162 162
163%% 163%%
164 164
165/* 165/*
166 * A configuration consists of a machine type, followed by the machine 166 * A complete configuration consists of both the configuration part (a
167 * definition files (via the include() mechanism), followed by the 167 * kernel config such as GENERIC or SKYNET, plus also the various
168 * configuration specification(s) proper. In effect, this is two 168 * std.* files), which selects the material to be in the kernel, and
169 * separate grammars, with some shared terminals and nonterminals. 169 * also the definition part (files, files.*, etc.) that declares what
170 * Note that we do not have sufficient keywords to enforce any order 170 * material is available to be placed in kernels.
171 * between elements of "topthings" without introducing shift/reduce 171 *
172 * conflicts. Instead, check order requirements in the C code. 172 * The two parts have almost entirely separate syntaxes. This grammar
 173 * covers both of them. When config is run on a kernel configuration
 174 * file, the std.* file for the port is included explicitly. The
 175 * files.* files are included implicitly when the std.* file declares
 176 * the machine type.
 177 *
 178 * The machine spec, which brings in the definition part, must appear
 179 * before all configuration material except for the "topthings"; these
 180 * are the "source" and "build" declarations that tell config where
 181 * things are. These are not used by default.
 182 *
 183 * A previous version of this comment contained the following text:
 184 *
 185 * Note that we do not have sufficient keywords to enforce any
 186 * order between elements of "topthings" without introducing
 187 * shift/reduce conflicts. Instead, check order requirements in
 188 * the C code.
 189 *
 190 * As of March 2012 this comment makes no sense, as there are only two
 191 * topthings and no reason for them to be forcibly ordered.
 192 * Furthermore, the statement about conflicts is false.
173 */ 193 */
 194
 195/* Complete configuration. */
174Configuration: 196Configuration:
175 topthings /* dirspecs, include "std.arch" */ 197 topthings
176 machine_spec /* "machine foo" from machine descr. */ 198 machine_spec
177 dev_defs ENDDEFS /* all machine definition files */ 199 dev_defs ENDDEFS
178 { check_maxpart(); check_version(); } 200 { check_maxpart(); check_version(); }
179 specs; /* rest of machine description */ 201 specs;
180 202
 203/* Sequence of zero or more topthings. */
181topthings: 204topthings:
182 topthings topthing | 205 topthings topthing |
183 /* empty */; 206 /* empty */;
184 207
 208/* Directory specification. */
185topthing: 209topthing:
186 SOURCE filename '\n' { if (!srcdir) srcdir = $2; } | 210 SOURCE filename '\n' { if (!srcdir) srcdir = $2; } |
187 BUILD filename '\n' { if (!builddir) builddir = $2; } | 211 BUILD filename '\n' { if (!builddir) builddir = $2; } |
188 '\n'; 212 '\n';
189 213
 214/* "machine foo" from std.whatever */
190machine_spec: 215machine_spec:
191 XMACHINE WORD '\n' { setmachine($2,NULL,NULL,0); } | 216 XMACHINE WORD '\n' { setmachine($2,NULL,NULL,0); } |
192 XMACHINE WORD WORD subarches_opt '\n' { setmachine($2,$3,$4,0); } | 217 XMACHINE WORD WORD subarches_opt '\n' { setmachine($2,$3,$4,0); } |
193 IOCONF WORD '\n' { setmachine($2,NULL,NULL,1); } | 218 IOCONF WORD '\n' { setmachine($2,NULL,NULL,1); } |
194 error { stop("cannot proceed without machine or ioconf specifier"); }; 219 error { stop("cannot proceed without machine or ioconf specifier"); };
195 220
 221/* Optional subarches. */
196subarches_opt: 222subarches_opt:
197 subarches | 223 subarches |
198 /* empty */ { $$ = NULL; }; 224 /* empty */ { $$ = NULL; };
199 225
 226/* Subarches declaration. */
200subarches: 227subarches:
201 subarches WORD { $$ = new_nx($2, $1); } | 228 subarches WORD { $$ = new_nx($2, $1); } |
202 WORD { $$ = new_n($1); }; 229 WORD { $$ = new_n($1); };
203 230
 231/************************************************************/
 232
204/* 233/*
205 * Various nonterminals shared between the grammars. 234 * Various nonterminals shared between the grammars.
 235 * (Note: that's a lie, pending some reorg)
206 */ 236 */
 237
 238/* source file: file foo/bar.c bar|baz needs-flag compile-with blah */
207file: 239file:
208 XFILE filename fopts fflgs rule { addfile($2, $3, $4, $5); }; 240 XFILE filename fopts fflgs rule { addfile($2, $3, $4, $5); };
209 241
 242/* object file: object zot.o foo|zot needs-flag */
210object: 243object:
211 XOBJECT filename fopts oflgs { addobject($2, $3, $4); }; 244 XOBJECT filename fopts oflgs { addobject($2, $3, $4); };
212 245
 246/* device major declaration */
213device_major: 247device_major:
214 DEVICE_MAJOR WORD device_major_char device_major_block fopts devnodes 248 DEVICE_MAJOR WORD device_major_char device_major_block fopts devnodes
215 { adddevm($2, $3, $4, $5, $6); }; 249 { adddevm($2, $3, $4, $5, $6); };
216 250/* block 33 */
217device_major_block: 251device_major_block:
218 BLOCK NUMBER { $$ = $2.val; } | 252 BLOCK NUMBER { $$ = $2.val; } |
219 /* empty */ { $$ = -1; }; 253 /* empty */ { $$ = -1; };
220 254
 255/* char 55 */
221device_major_char: 256device_major_char:
222 CHAR NUMBER { $$ = $2.val; } | 257 CHAR NUMBER { $$ = $2.val; } |
223 /* empty */ { $$ = -1; }; 258 /* empty */ { $$ = -1; };
224 259
225/* order of options is important, must use right recursion */ 260/*
 261 * order of options is important, must use right recursion
 262 *
 263 * dholland 20120310: wut?
 264 */
 265
 266/* file options: optional expression of config elements */
226fopts: 267fopts:
227 fexpr { $$ = $1; } | 268 fexpr { $$ = $1; } |
228 /* empty */ { $$ = NULL; }; 269 /* empty */ { $$ = NULL; };
229 270
 271/* expression of config elements */
 272/* XXX this should use a real expression grammar */
230fexpr: 273fexpr:
231 fatom { $$ = $1; } | 274 fatom { $$ = $1; } |
232 '!' fatom { $$ = fx_not($2); } | 275 '!' fatom { $$ = fx_not($2); } |
233 fexpr '&' fexpr { $$ = fx_and($1, $3); } | 276 fexpr '&' fexpr { $$ = fx_and($1, $3); } |
234 fexpr '|' fexpr { $$ = fx_or($1, $3); } | 277 fexpr '|' fexpr { $$ = fx_or($1, $3); } |
235 '(' fexpr ')' { $$ = $2; }; 278 '(' fexpr ')' { $$ = $2; };
236 279
 280/* basic element of config element expression: a config element */
237fatom: 281fatom:
238 WORD { $$ = fx_atom($1); }; 282 WORD { $$ = fx_atom($1); };
239 283
 284/* zero or more flags for a file */
240fflgs: 285fflgs:
241 fflgs fflag { $$ = $1 | $2; } | 286 fflgs fflag { $$ = $1 | $2; } |
242 /* empty */ { $$ = 0; }; 287 /* empty */ { $$ = 0; };
243 288
 289/* one flag for a file */
244fflag: 290fflag:
245 NEEDS_COUNT { $$ = FI_NEEDSCOUNT; } | 291 NEEDS_COUNT { $$ = FI_NEEDSCOUNT; } |
246 NEEDS_FLAG { $$ = FI_NEEDSFLAG; }; 292 NEEDS_FLAG { $$ = FI_NEEDSFLAG; };
247 293
 294/* device node specification */
248devnodes: 295devnodes:
249 devnodetype ',' devnodeflags { $$ = nvcat($1, $3); } | 296 devnodetype ',' devnodeflags { $$ = nvcat($1, $3); } |
250 devnodetype { $$ = $1; } | 297 devnodetype { $$ = $1; } |
251 /* empty */ { $$ = new_s("DEVNODE_DONTBOTHER"); }; 298 /* empty */ { $$ = new_s("DEVNODE_DONTBOTHER"); };
252 299
 300/* device nodes without flags */
253devnodetype: 301devnodetype:
254 SINGLE { $$ = new_s("DEVNODE_SINGLE"); } | 302 SINGLE { $$ = new_s("DEVNODE_SINGLE"); } |
255 VECTOR '=' devnode_dims { $$ = nvcat(new_s("DEVNODE_VECTOR"), $3); }; 303 VECTOR '=' devnode_dims { $$ = nvcat(new_s("DEVNODE_VECTOR"), $3); };
256 304
 305/* dimensions (?) */
257devnode_dims: 306devnode_dims:
258 NUMBER ':' NUMBER { struct nvlist *__nv1, *__nv2; 307 NUMBER ':' NUMBER { struct nvlist *__nv1, *__nv2;
259 __nv1 = new_i($1.val); 308 __nv1 = new_i($1.val);
260 __nv2 = new_i($3.val); 309 __nv2 = new_i($3.val);
261 $$ = nvcat(__nv1, __nv2); } | 310 $$ = nvcat(__nv1, __nv2); } |
262 NUMBER { $$ = new_i($1.val); } 311 NUMBER { $$ = new_i($1.val); }
263 312
 313/* flags for device nodes */
264devnodeflags: 314devnodeflags:
265 LINKZERO { $$ = new_s("DEVNODE_FLAG_LINKZERO");}; 315 LINKZERO { $$ = new_s("DEVNODE_FLAG_LINKZERO");};
266  316
 317/* zero or more flags for an object file */
267oflgs: 318oflgs:
268 oflgs oflag { $$ = $1 | $2; } | 319 oflgs oflag { $$ = $1 | $2; } |
269 /* empty */ { $$ = 0; }; 320 /* empty */ { $$ = 0; };
270 321
 322/* a single flag for an object file */
271oflag: 323oflag:
272 NEEDS_FLAG { $$ = OI_NEEDSFLAG; }; 324 NEEDS_FLAG { $$ = OI_NEEDSFLAG; };
273 325
 326/* extra compile directive for a source file */
274rule: 327rule:
275 COMPILE_WITH stringvalue { $$ = $2; } | 328 COMPILE_WITH stringvalue { $$ = $2; } |
276 /* empty */ { $$ = NULL; }; 329 /* empty */ { $$ = NULL; };
277 330
 331/* prefix delimiter */
278prefix: 332prefix:
279 PREFIX filename { prefix_push($2); } | 333 PREFIX filename { prefix_push($2); } |
280 PREFIX { prefix_pop(); }; 334 PREFIX { prefix_pop(); };
281 335
 336/************************************************************/
 337
282/* 338/*
283 * The machine definitions grammar. 339 * The machine definitions grammar.
284 */ 340 */
 341
 342/* Complete definition part: the contents of all files.* files. */
285dev_defs: 343dev_defs:
286 dev_defs dev_def | 344 dev_defs dev_def |
287 dev_defs ENDFILE { enddefs(); checkfiles(); } | 345 dev_defs ENDFILE { enddefs(); checkfiles(); } |
288 /* empty */; 346 /* empty */;
289 347
 348/* A single definition, or a blank line. Trap errors. */
290dev_def: 349dev_def:
291 one_def '\n' { adepth = 0; } | 350 one_def '\n' { adepth = 0; } |
292 '\n' | 351 '\n' |
293 error '\n' { cleanup(); }; 352 error '\n' { cleanup(); };
294 353
 354/* A single definition. */
295one_def: 355one_def:
296 file | 356 file |
297 object | 357 object |
298 device_major { do_devsw = 1; } | 358 device_major { do_devsw = 1; } |
299 prefix | 359 prefix |
300 DEVCLASS WORD { (void)defattr($2, NULL, NULL, 1); } | 360 DEVCLASS WORD { (void)defattr($2, NULL, NULL, 1); } |
301 DEFFS deffses defoptdeps { deffilesystem($2, $3); } | 361 DEFFS deffses defoptdeps { deffilesystem($2, $3); } |
302 DEFINE WORD interface_opt attrs_opt 362 DEFINE WORD interface_opt attrs_opt
303 { (void)defattr($2, $3, $4, 0); } | 363 { (void)defattr($2, $3, $4, 0); } |
304 DEFOPT optfile_opt defopts defoptdeps 364 DEFOPT optfile_opt defopts defoptdeps
305 { defoption($2, $3, $4); } | 365 { defoption($2, $3, $4); } |
306 DEFFLAG optfile_opt defopts defoptdeps 366 DEFFLAG optfile_opt defopts defoptdeps
307 { defflag($2, $3, $4, 0); } | 367 { defflag($2, $3, $4, 0); } |
@@ -316,307 +376,380 @@ one_def: @@ -316,307 +376,380 @@ one_def:
316 ATTACH devbase AT atlist devattach_opt attrs_opt 376 ATTACH devbase AT atlist devattach_opt attrs_opt
317 { defdevattach($5, $2, $4, $6); } | 377 { defdevattach($5, $2, $4, $6); } |
318 MAXPARTITIONS NUMBER { maxpartitions = $2.val; } | 378 MAXPARTITIONS NUMBER { maxpartitions = $2.val; } |
319 MAXUSERS NUMBER NUMBER NUMBER { setdefmaxusers($2.val, $3.val, $4.val); } | 379 MAXUSERS NUMBER NUMBER NUMBER { setdefmaxusers($2.val, $3.val, $4.val); } |
320 MAKEOPTIONS condmkopt_list | 380 MAKEOPTIONS condmkopt_list |
321 /* interface_opt in DEFPSEUDO is for backwards compatibility */ 381 /* interface_opt in DEFPSEUDO is for backwards compatibility */
322 DEFPSEUDO devbase interface_opt attrs_opt 382 DEFPSEUDO devbase interface_opt attrs_opt
323 { defdev($2, $3, $4, 1); } | 383 { defdev($2, $3, $4, 1); } |
324 DEFPSEUDODEV devbase interface_opt attrs_opt 384 DEFPSEUDODEV devbase interface_opt attrs_opt
325 { defdev($2, $3, $4, 2); } | 385 { defdev($2, $3, $4, 2); } |
326 MAJOR '{' majorlist '}' | 386 MAJOR '{' majorlist '}' |
327 VERSION NUMBER { setversion($2.val); }; 387 VERSION NUMBER { setversion($2.val); };
328 388
 389/* list of places to attach: attach blah at ... */
329atlist: 390atlist:
330 atlist ',' atname { $$ = new_nx($3, $1); } | 391 atlist ',' atname { $$ = new_nx($3, $1); } |
331 atname { $$ = new_n($1); }; 392 atname { $$ = new_n($1); };
332 393
 394/* a place to attach a device */
333atname: 395atname:
334 WORD { $$ = $1; } | 396 WORD { $$ = $1; } |
335 ROOT { $$ = NULL; }; 397 ROOT { $$ = NULL; };
336 398
 399/* one or more file system names */
337deffses: 400deffses:
338 deffses deffs { $$ = new_nx($2, $1); } | 401 deffses deffs { $$ = new_nx($2, $1); } |
339 deffs { $$ = new_n($1); }; 402 deffs { $$ = new_n($1); };
340 403
 404/* a single file system name */
341deffs: 405deffs:
342 WORD { $$ = $1; }; 406 WORD { $$ = $1; };
343 407
 408/* option dependencies (read as "defopt deps") which are optional */
344defoptdeps: 409defoptdeps:
345 ':' optdeps { $$ = $2; } | 410 ':' optdeps { $$ = $2; } |
346 /* empty */ { $$ = NULL; }; 411 /* empty */ { $$ = NULL; };
347 412
 413/* a list of option dependencies */
348optdeps: 414optdeps:
349 optdeps ',' optdep { $$ = new_nx($3, $1); } | 415 optdeps ',' optdep { $$ = new_nx($3, $1); } |
350 optdep { $$ = new_n($1); }; 416 optdep { $$ = new_n($1); };
351 417
 418/* one option dependence */
352optdep: 419optdep:
353 WORD { $$ = $1; }; 420 WORD { $$ = $1; };
354 421
 422/* one or more defined options */
355defopts: 423defopts:
356 defopts defopt { $$ = nvcat($2, $1); } | 424 defopts defopt { $$ = nvcat($2, $1); } |
357 defopt { $$ = $1; }; 425 defopt { $$ = $1; };
358 426
 427/* one defined option */
359defopt: 428defopt:
360 WORD { $$ = new_n($1); } | 429 WORD { $$ = new_n($1); } |
361 WORD '=' value { $$ = new_ns($1, $3); } | 430 WORD '=' value { $$ = new_ns($1, $3); } |
362 WORD COLONEQ value { 431 WORD COLONEQ value {
363 struct nvlist *__nv = 432 struct nvlist *__nv =
364 new_n($1); 433 new_n($1);
365 $$ = new_nsx("", $3, __nv); 434 $$ = new_nsx("", $3, __nv);
366 } | 435 } |
367 WORD '=' value COLONEQ value { 436 WORD '=' value COLONEQ value {
368 struct nvlist *__nv = 437 struct nvlist *__nv =
369 new_n($1); 438 new_n($1);
370 $$ = new_nsx("", $5, __nv); 439 $$ = new_nsx("", $5, __nv);
371 }; 440 };
372 441
 442/* device name */
373devbase: 443devbase:
374 WORD { $$ = getdevbase($1); }; 444 WORD { $$ = getdevbase($1); };
375 445
 446/* optional attachment: with foo */
376devattach_opt: 447devattach_opt:
377 WITH WORD { $$ = getdevattach($2); } | 448 WITH WORD { $$ = getdevattach($2); } |
378 /* empty */ { $$ = NULL; }; 449 /* empty */ { $$ = NULL; };
379 450
 451/* optional locator specification in braces */
380interface_opt: 452interface_opt:
381 '{' loclist_opt '}' { $$ = new_nx("", $2); } | 453 '{' loclist_opt '}' { $$ = new_nx("", $2); } |
382 /* empty */ { $$ = NULL; }; 454 /* empty */ { $$ = NULL; };
383 455
 456/* optional locator specification without braces */
384loclist_opt: 457loclist_opt:
385 loclist { $$ = $1; } | 458 loclist { $$ = $1; } |
386 /* empty */ { $$ = NULL; }; 459 /* empty */ { $$ = NULL; };
387 460
388/* loclist order matters, must use right recursion */ 461/*
 462 * loclist order matters, must use right recursion
 463 * XXX wot?
 464 */
 465
 466/* list of locator definitions */
389loclist: 467loclist:
390 locdef ',' loclist { $$ = $1; app($1, $3); } | 468 locdef ',' loclist { $$ = $1; app($1, $3); } |
391 locdef { $$ = $1; }; 469 locdef { $$ = $1; };
392 470
393/* "[ WORD locdefault ]" syntax may be unnecessary... */ 471/*
 472 * "[ WORD locdefault ]" syntax may be unnecessary...
 473 */
 474
 475/* one locator definition */
394locdef: 476locdef:
395 locname locdefault { $$ = new_nsi($1, $2, 0); } | 477 locname locdefault { $$ = new_nsi($1, $2, 0); } |
396 locname { $$ = new_nsi($1, NULL, 0); } | 478 locname { $$ = new_nsi($1, NULL, 0); } |
397 '[' locname locdefault ']' { $$ = new_nsi($2, $3, 1); } | 479 '[' locname locdefault ']' { $$ = new_nsi($2, $3, 1); } |
398 locname '[' NUMBER ']' { $$ = mk_nsis($1, $3.val, NULL, 0); } | 480 locname '[' NUMBER ']' { $$ = mk_nsis($1, $3.val, NULL, 0); } |
399 locname '[' NUMBER ']' locdefaults 481 locname '[' NUMBER ']' locdefaults
400 { $$ = mk_nsis($1, $3.val, $5, 0); } | 482 { $$ = mk_nsis($1, $3.val, $5, 0); } |
401 '[' locname '[' NUMBER ']' locdefaults ']' 483 '[' locname '[' NUMBER ']' locdefaults ']'
402 { $$ = mk_nsis($2, $4.val, $6, 1); }; 484 { $$ = mk_nsis($2, $4.val, $6, 1); };
403 485
 486/* locator name */
404locname: 487locname:
405 WORD { $$ = $1; } | 488 WORD { $$ = $1; } |
406 QSTRING { $$ = $1; }; 489 QSTRING { $$ = $1; };
407 490
 491/* locator default value */
408locdefault: 492locdefault:
409 '=' value { $$ = $2; }; 493 '=' value { $$ = $2; };
410 494
 495/* multiple locator default values */
411locdefaults: 496locdefaults:
412 '=' '{' values '}' { $$ = $3; }; 497 '=' '{' values '}' { $$ = $3; };
413 498
 499/* optional file for an option */
414optfile_opt: 500optfile_opt:
415 filename { $$ = $1; } | 501 filename { $$ = $1; } |
416 /* empty */ { $$ = NULL; }; 502 /* empty */ { $$ = NULL; };
417 503
 504/* filename. */
418filename: 505filename:
419 QSTRING { $$ = $1; } | 506 QSTRING { $$ = $1; } |
420 PATHNAME { $$ = $1; }; 507 PATHNAME { $$ = $1; };
421 508
 509/* constant value */
422value: 510value:
423 QSTRING { $$ = $1; } | 511 QSTRING { $$ = $1; } |
424 WORD { $$ = $1; } | 512 WORD { $$ = $1; } |
425 EMPTYSTRING { $$ = $1; } | 513 EMPTYSTRING { $$ = $1; } |
426 signed_number { char bf[40]; 514 signed_number { char bf[40];
427 (void)snprintf(bf, sizeof(bf), 515 (void)snprintf(bf, sizeof(bf),
428 FORMAT($1), (long long)$1.val); 516 FORMAT($1), (long long)$1.val);
429 $$ = intern(bf); }; 517 $$ = intern(bf); };
430 518
 519/* constant value that is a string */
431stringvalue: 520stringvalue:
432 QSTRING { $$ = $1; } | 521 QSTRING { $$ = $1; } |
433 WORD { $$ = $1; }; 522 WORD { $$ = $1; };
434 523
 524/* comma-separated list of values */
435values: 525values:
436 value ',' values { $$ = new_sx($1, $3); } | 526 value ',' values { $$ = new_sx($1, $3); } |
437 value { $$ = new_s($1); }; 527 value { $$ = new_s($1); };
438 528
 529/* possibly negative number */
439signed_number: 530signed_number:
440 NUMBER { $$ = $1; } | 531 NUMBER { $$ = $1; } |
441 '-' NUMBER { $$.fmt = $2.fmt; $$.val = -$2.val; }; 532 '-' NUMBER { $$.fmt = $2.fmt; $$.val = -$2.val; };
442 533
 534/* optional attributes */
443attrs_opt: 535attrs_opt:
444 ':' attrs { $$ = $2; } | 536 ':' attrs { $$ = $2; } |
445 /* empty */ { $$ = NULL; }; 537 /* empty */ { $$ = NULL; };
446 538
 539/* one or more attributes */
447attrs: 540attrs:
448 attrs ',' attr { $$ = new_px($3, $1); } | 541 attrs ',' attr { $$ = new_px($3, $1); } |
449 attr { $$ = new_p($1); }; 542 attr { $$ = new_p($1); };
450 543
 544/* one attribute */
451attr: 545attr:
452 WORD { $$ = getattr($1); }; 546 WORD { $$ = getattr($1); };
453 547
 548/* list of major numbers */
 549/* XXX why is this right-recursive? */
454majorlist: 550majorlist:
455 majorlist ',' majordef | 551 majorlist ',' majordef |
456 majordef; 552 majordef;
457 553
 554/* one major number */
458majordef: 555majordef:
459 devbase '=' NUMBER { setmajor($1, $3.val); }; 556 devbase '=' NUMBER { setmajor($1, $3.val); };
460 557
 558/************************************************************/
461 559
462/* 560/*
463 * The configuration grammar. 561 * The configuration grammar.
464 */ 562 */
 563
 564/* Complete configuration part: all std.* files plus selected config. */
465specs: 565specs:
466 specs spec | 566 specs spec |
467 /* empty */; 567 /* empty */;
468 568
 569/* One config item, or a blank line. Trap errors. */
469spec: 570spec:
470 config_spec '\n' { adepth = 0; } | 571 config_spec '\n' { adepth = 0; } |
471 '\n' | 572 '\n' |
472 error '\n' { cleanup(); }; 573 error '\n' { cleanup(); };
473 574
 575/* One config item. */
474config_spec: 576config_spec:
475 one_def | 577 one_def |
476 NO FILE_SYSTEM no_fs_list | 578 NO FILE_SYSTEM no_fs_list |
477 FILE_SYSTEM fs_list | 579 FILE_SYSTEM fs_list |
478 NO MAKEOPTIONS no_mkopt_list | 580 NO MAKEOPTIONS no_mkopt_list |
479 MAKEOPTIONS mkopt_list | 581 MAKEOPTIONS mkopt_list |
480 NO OPTIONS no_opt_list | 582 NO OPTIONS no_opt_list |
481 OPTIONS opt_list | 583 OPTIONS opt_list |
482 MAXUSERS NUMBER { setmaxusers($2.val); } | 584 MAXUSERS NUMBER { setmaxusers($2.val); } |
483 IDENT stringvalue { setident($2); } | 585 IDENT stringvalue { setident($2); } |
484 CONFIG conf root_spec sysparam_list 586 CONFIG conf root_spec sysparam_list
485 { addconf(&conf); } | 587 { addconf(&conf); } |
486 NO CONFIG WORD { delconf($3); } | 588 NO CONFIG WORD { delconf($3); } |
487 NO PSEUDO_DEVICE WORD { delpseudo($3); } | 589 NO PSEUDO_DEVICE WORD { delpseudo($3); } |
488 PSEUDO_DEVICE WORD npseudo { addpseudo($2, $3); } | 590 PSEUDO_DEVICE WORD npseudo { addpseudo($2, $3); } |
489 PSEUDO_ROOT device_instance { addpseudoroot($2); } | 591 PSEUDO_ROOT device_instance { addpseudoroot($2); } |
490 NO device_instance AT attachment 592 NO device_instance AT attachment
491 { deldevi($2, $4); } | 593 { deldevi($2, $4); } |
492 NO DEVICE AT attachment { deldeva($4); } | 594 NO DEVICE AT attachment { deldeva($4); } |
493 NO device_instance { deldev($2); } | 595 NO device_instance { deldev($2); } |
494 device_instance AT attachment locators flags_opt 596 device_instance AT attachment locators flags_opt
495 { adddev($1, $3, $4, $5); }; 597 { adddev($1, $3, $4, $5); };
496 598
 599/* list of filesystems */
497fs_list: 600fs_list:
498 fs_list ',' fsoption | 601 fs_list ',' fsoption |
499 fsoption; 602 fsoption;
500 603
 604/* one filesystem */
501fsoption: 605fsoption:
502 WORD { addfsoption($1); }; 606 WORD { addfsoption($1); };
503 607
 608/* list of filesystems that had NO in front */
504no_fs_list: 609no_fs_list:
505 no_fs_list ',' no_fsoption | 610 no_fs_list ',' no_fsoption |
506 no_fsoption; 611 no_fsoption;
507 612
 613/* one filesystem that had NO in front */
508no_fsoption: 614no_fsoption:
509 WORD { delfsoption($1); }; 615 WORD { delfsoption($1); };
510 616
 617/* list of make options */
 618/* XXX why is this right-recursive? */
511mkopt_list: 619mkopt_list:
512 mkopt_list ',' mkoption | 620 mkopt_list ',' mkoption |
513 mkoption; 621 mkoption;
514 622
 623/* variable name for make option */
515mkvarname: 624mkvarname:
516 QSTRING { $$ = $1; } | 625 QSTRING { $$ = $1; } |
517 WORD { $$ = $1; }; 626 WORD { $$ = $1; };
518 627
 628/* one make option */
519mkoption: 629mkoption:
520 mkvarname '=' value { addmkoption($1, $3); } | 630 mkvarname '=' value { addmkoption($1, $3); } |
521 mkvarname PLUSEQ value { appendmkoption($1, $3); }; 631 mkvarname PLUSEQ value { appendmkoption($1, $3); };
522 632
 633/* list of conditional makeoptions */
523condmkopt_list: 634condmkopt_list:
524 condmkopt_list ',' condmkoption | 635 condmkopt_list ',' condmkoption |
525 condmkoption; 636 condmkoption;
526 637
 638/* one conditional make option */
527condmkoption: 639condmkoption:
528 fexpr mkvarname PLUSEQ value { appendcondmkoption($1, $2, $4); }; 640 fexpr mkvarname PLUSEQ value { appendcondmkoption($1, $2, $4); };
529 641
 642/* list of make options that had NO in front */
530no_mkopt_list: 643no_mkopt_list:
531 no_mkopt_list ',' no_mkoption | 644 no_mkopt_list ',' no_mkoption |
532 no_mkoption; 645 no_mkoption;
533 646
 647/* one make option that had NO in front */
534no_mkoption: 648no_mkoption:
535 WORD { delmkoption($1); } 649 WORD { delmkoption($1); }
536 650
 651/* list of options */
537opt_list: 652opt_list:
538 opt_list ',' option | 653 opt_list ',' option |
539 option; 654 option;
540 655
 656/* one option */
541option: 657option:
542 WORD { addoption($1, NULL); } | 658 WORD { addoption($1, NULL); } |
543 WORD '=' value { addoption($1, $3); }; 659 WORD '=' value { addoption($1, $3); };
544 660
 661/* list of options that had NO in front */
545no_opt_list: 662no_opt_list:
546 no_opt_list ',' no_option | 663 no_opt_list ',' no_option |
547 no_option; 664 no_option;
548 665
 666/* one option that had NO in front */
549no_option: 667no_option:
550 WORD { deloption($1); }; 668 WORD { deloption($1); };
551 669
 670/* the name in "config name root on ..." */
552conf: 671conf:
553 WORD { conf.cf_name = $1; 672 WORD { conf.cf_name = $1;
554 conf.cf_lineno = currentline(); 673 conf.cf_lineno = currentline();
555 conf.cf_fstype = NULL; 674 conf.cf_fstype = NULL;
556 conf.cf_root = NULL; 675 conf.cf_root = NULL;
557 conf.cf_dump = NULL; }; 676 conf.cf_dump = NULL; };
558 677
 678/* root fs specification */
559root_spec: 679root_spec:
560 ROOT on_opt dev_spec fs_spec_opt 680 ROOT on_opt dev_spec fs_spec_opt
561 { setconf(&conf.cf_root, "root", $3); }; 681 { setconf(&conf.cf_root, "root", $3); };
562 682
 683/* filesystem type for root fs specification */
563fs_spec_opt: 684fs_spec_opt:
564 TYPE fs_spec { setfstype(&conf.cf_fstype, $2); } | 685 TYPE fs_spec { setfstype(&conf.cf_fstype, $2); } |
565 /* empty */; 686 /* empty */;
566 687
 688/* filesystem name for root fs specification */
567fs_spec: 689fs_spec:
568 '?' { $$ = intern("?"); } | 690 '?' { $$ = intern("?"); } |
569 WORD { $$ = $1; }; 691 WORD { $$ = $1; };
570 692
 693/* zero or more additional system parameters */
571sysparam_list: 694sysparam_list:
572 sysparam_list sysparam | 695 sysparam_list sysparam |
573 /* empty */; 696 /* empty */;
574 697
 698/* one additional system parameter (there's only one: dumps) */
575sysparam: 699sysparam:
576 DUMPS on_opt dev_spec { setconf(&conf.cf_dump, "dumps", $3); }; 700 DUMPS on_opt dev_spec { setconf(&conf.cf_dump, "dumps", $3); };
577 701
 702/* device for root fs or dump */
578dev_spec: 703dev_spec:
579 '?' { $$ = new_si(intern("?"), NODEV); } | 704 '?' { $$ = new_si(intern("?"), NODEV); } |
580 WORD { $$ = new_si($1, NODEV); } | 705 WORD { $$ = new_si($1, NODEV); } |
581 major_minor { $$ = new_si(NULL, $1); }; 706 major_minor { $$ = new_si(NULL, $1); };
582 707
 708/* major and minor device number */
583major_minor: 709major_minor:
584 MAJOR NUMBER MINOR NUMBER { $$ = makedev($2.val, $4.val); }; 710 MAJOR NUMBER MINOR NUMBER { $$ = makedev($2.val, $4.val); };
585 711
 712/* optional ON keyword */
586on_opt: 713on_opt:
587 ON | /* empty */; 714 ON | /* empty */;
588 715
 716/* number of pseudo devices to configure (which is optional) */
589npseudo: 717npseudo:
590 NUMBER { $$ = $1.val; } | 718 NUMBER { $$ = $1.val; } |
591 /* empty */ { $$ = 1; }; 719 /* empty */ { $$ = 1; };
592 720
 721/* name of a device to configure */
593device_instance: 722device_instance:
594 WORD '*' { $$ = starref($1); } | 723 WORD '*' { $$ = starref($1); } |
595 WORD { $$ = $1; }; 724 WORD { $$ = $1; };
596 725
 726/* name of a device to configure an attachment to */
597attachment: 727attachment:
598 ROOT { $$ = NULL; } | 728 ROOT { $$ = NULL; } |
599 WORD '?' { $$ = wildref($1); } | 729 WORD '?' { $$ = wildref($1); } |
600 WORD { $$ = $1; }; 730 WORD { $$ = $1; };
601 731
 732/* zero or more locators */
602locators: 733locators:
603 locators locator { $$ = $2; app($2, $1); } | 734 locators locator { $$ = $2; app($2, $1); } |
604 /* empty */ { $$ = NULL; }; 735 /* empty */ { $$ = NULL; };
605 736
 737/* one locator */
606locator: 738locator:
607 WORD values { $$ = mk_ns($1, $2); } | 739 WORD values { $$ = mk_ns($1, $2); } |
608 WORD '?' { $$ = new_ns($1, NULL); }; 740 WORD '?' { $$ = new_ns($1, NULL); };
609 741
 742/* optional device flags */
610flags_opt: 743flags_opt:
611 FLAGS NUMBER { $$ = $2.val; } | 744 FLAGS NUMBER { $$ = $2.val; } |
612 /* empty */ { $$ = 0; }; 745 /* empty */ { $$ = 0; };
613 746
614%% 747%%
615 748
616void 749void
617yyerror(const char *s) 750yyerror(const char *s)
618{ 751{
619 752
620 cfgerror("%s", s); 753 cfgerror("%s", s);
621} 754}
622 755