Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/config Comments.
details: https://anonhg.NetBSD.org/src/rev/7e441487d72b
branches: trunk
changeset: 777955:7e441487d72b
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Mar 11 00:14:20 2012 +0000
description:
Comments.
diffstat:
usr.bin/config/gram.y | 167 ++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 150 insertions(+), 17 deletions(-)
diffs (truncated from 555 to 300 lines):
diff -r 2a16b3292e8a -r 7e441487d72b usr.bin/config/gram.y
--- a/usr.bin/config/gram.y Sun Mar 11 00:02:04 2012 +0000
+++ b/usr.bin/config/gram.y Sun Mar 11 00:14:20 2012 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: gram.y,v 1.24 2010/04/30 20:47:18 pooka Exp $ */
+/* $NetBSD: gram.y,v 1.25 2012/03/11 00:14:20 dholland Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -163,70 +163,113 @@
%%
/*
- * A configuration consists of a machine type, followed by the machine
- * definition files (via the include() mechanism), followed by the
- * configuration specification(s) proper. In effect, this is two
- * separate grammars, with some shared terminals and nonterminals.
- * Note that we do not have sufficient keywords to enforce any order
- * between elements of "topthings" without introducing shift/reduce
- * conflicts. Instead, check order requirements in the C code.
+ * A complete configuration consists of both the configuration part (a
+ * kernel config such as GENERIC or SKYNET, plus also the various
+ * std.* files), which selects the material to be in the kernel, and
+ * also the definition part (files, files.*, etc.) that declares what
+ * material is available to be placed in kernels.
+ *
+ * The two parts have almost entirely separate syntaxes. This grammar
+ * covers both of them. When config is run on a kernel configuration
+ * file, the std.* file for the port is included explicitly. The
+ * files.* files are included implicitly when the std.* file declares
+ * the machine type.
+ *
+ * The machine spec, which brings in the definition part, must appear
+ * before all configuration material except for the "topthings"; these
+ * are the "source" and "build" declarations that tell config where
+ * things are. These are not used by default.
+ *
+ * A previous version of this comment contained the following text:
+ *
+ * Note that we do not have sufficient keywords to enforce any
+ * order between elements of "topthings" without introducing
+ * shift/reduce conflicts. Instead, check order requirements in
+ * the C code.
+ *
+ * As of March 2012 this comment makes no sense, as there are only two
+ * topthings and no reason for them to be forcibly ordered.
+ * Furthermore, the statement about conflicts is false.
*/
+
+/* Complete configuration. */
Configuration:
- topthings /* dirspecs, include "std.arch" */
- machine_spec /* "machine foo" from machine descr. */
- dev_defs ENDDEFS /* all machine definition files */
+ topthings
+ machine_spec
+ dev_defs ENDDEFS
{ check_maxpart(); check_version(); }
- specs; /* rest of machine description */
+ specs;
+/* Sequence of zero or more topthings. */
topthings:
topthings topthing |
/* empty */;
+/* Directory specification. */
topthing:
SOURCE filename '\n' { if (!srcdir) srcdir = $2; } |
BUILD filename '\n' { if (!builddir) builddir = $2; } |
'\n';
+/* "machine foo" from std.whatever */
machine_spec:
XMACHINE WORD '\n' { setmachine($2,NULL,NULL,0); } |
XMACHINE WORD WORD subarches_opt '\n' { setmachine($2,$3,$4,0); } |
IOCONF WORD '\n' { setmachine($2,NULL,NULL,1); } |
error { stop("cannot proceed without machine or ioconf specifier"); };
+/* Optional subarches. */
subarches_opt:
subarches |
/* empty */ { $$ = NULL; };
+/* Subarches declaration. */
subarches:
subarches WORD { $$ = new_nx($2, $1); } |
WORD { $$ = new_n($1); };
+/************************************************************/
+
/*
* Various nonterminals shared between the grammars.
+ * (Note: that's a lie, pending some reorg)
*/
+
+/* source file: file foo/bar.c bar|baz needs-flag compile-with blah */
file:
XFILE filename fopts fflgs rule { addfile($2, $3, $4, $5); };
+/* object file: object zot.o foo|zot needs-flag */
object:
XOBJECT filename fopts oflgs { addobject($2, $3, $4); };
+/* device major declaration */
device_major:
DEVICE_MAJOR WORD device_major_char device_major_block fopts devnodes
{ adddevm($2, $3, $4, $5, $6); };
-
+/* block 33 */
device_major_block:
BLOCK NUMBER { $$ = $2.val; } |
/* empty */ { $$ = -1; };
+/* char 55 */
device_major_char:
CHAR NUMBER { $$ = $2.val; } |
/* empty */ { $$ = -1; };
-/* order of options is important, must use right recursion */
+/*
+ * order of options is important, must use right recursion
+ *
+ * dholland 20120310: wut?
+ */
+
+/* file options: optional expression of config elements */
fopts:
fexpr { $$ = $1; } |
/* empty */ { $$ = NULL; };
+/* expression of config elements */
+/* XXX this should use a real expression grammar */
fexpr:
fatom { $$ = $1; } |
'!' fatom { $$ = fx_not($2); } |
@@ -234,26 +277,32 @@
fexpr '|' fexpr { $$ = fx_or($1, $3); } |
'(' fexpr ')' { $$ = $2; };
+/* basic element of config element expression: a config element */
fatom:
WORD { $$ = fx_atom($1); };
+/* zero or more flags for a file */
fflgs:
fflgs fflag { $$ = $1 | $2; } |
/* empty */ { $$ = 0; };
+/* one flag for a file */
fflag:
NEEDS_COUNT { $$ = FI_NEEDSCOUNT; } |
NEEDS_FLAG { $$ = FI_NEEDSFLAG; };
+/* device node specification */
devnodes:
devnodetype ',' devnodeflags { $$ = nvcat($1, $3); } |
devnodetype { $$ = $1; } |
/* empty */ { $$ = new_s("DEVNODE_DONTBOTHER"); };
+/* device nodes without flags */
devnodetype:
SINGLE { $$ = new_s("DEVNODE_SINGLE"); } |
VECTOR '=' devnode_dims { $$ = nvcat(new_s("DEVNODE_VECTOR"), $3); };
+/* dimensions (?) */
devnode_dims:
NUMBER ':' NUMBER { struct nvlist *__nv1, *__nv2;
__nv1 = new_i($1.val);
@@ -261,37 +310,48 @@
$$ = nvcat(__nv1, __nv2); } |
NUMBER { $$ = new_i($1.val); }
+/* flags for device nodes */
devnodeflags:
LINKZERO { $$ = new_s("DEVNODE_FLAG_LINKZERO");};
-
+
+/* zero or more flags for an object file */
oflgs:
oflgs oflag { $$ = $1 | $2; } |
/* empty */ { $$ = 0; };
+/* a single flag for an object file */
oflag:
NEEDS_FLAG { $$ = OI_NEEDSFLAG; };
+/* extra compile directive for a source file */
rule:
COMPILE_WITH stringvalue { $$ = $2; } |
/* empty */ { $$ = NULL; };
+/* prefix delimiter */
prefix:
PREFIX filename { prefix_push($2); } |
PREFIX { prefix_pop(); };
+/************************************************************/
+
/*
* The machine definitions grammar.
*/
+
+/* Complete definition part: the contents of all files.* files. */
dev_defs:
dev_defs dev_def |
dev_defs ENDFILE { enddefs(); checkfiles(); } |
/* empty */;
+/* A single definition, or a blank line. Trap errors. */
dev_def:
one_def '\n' { adepth = 0; } |
'\n' |
error '\n' { cleanup(); };
+/* A single definition. */
one_def:
file |
object |
@@ -326,36 +386,45 @@
MAJOR '{' majorlist '}' |
VERSION NUMBER { setversion($2.val); };
+/* list of places to attach: attach blah at ... */
atlist:
atlist ',' atname { $$ = new_nx($3, $1); } |
atname { $$ = new_n($1); };
+/* a place to attach a device */
atname:
WORD { $$ = $1; } |
ROOT { $$ = NULL; };
+/* one or more file system names */
deffses:
deffses deffs { $$ = new_nx($2, $1); } |
deffs { $$ = new_n($1); };
+/* a single file system name */
deffs:
WORD { $$ = $1; };
+/* option dependencies (read as "defopt deps") which are optional */
defoptdeps:
':' optdeps { $$ = $2; } |
/* empty */ { $$ = NULL; };
+/* a list of option dependencies */
optdeps:
optdeps ',' optdep { $$ = new_nx($3, $1); } |
optdep { $$ = new_n($1); };
+/* one option dependence */
optdep:
WORD { $$ = $1; };
+/* one or more defined options */
defopts:
defopts defopt { $$ = nvcat($2, $1); } |
defopt { $$ = $1; };
+/* one defined option */
defopt:
WORD { $$ = new_n($1); } |
WORD '=' value { $$ = new_ns($1, $3); } |
@@ -370,27 +439,40 @@
$$ = new_nsx("", $5, __nv);
};
+/* device name */
devbase:
WORD { $$ = getdevbase($1); };
+/* optional attachment: with foo */
devattach_opt:
WITH WORD { $$ = getdevattach($2); } |
/* empty */ { $$ = NULL; };
+/* optional locator specification in braces */
interface_opt:
'{' loclist_opt '}' { $$ = new_nx("", $2); } |
/* empty */ { $$ = NULL; };
+/* optional locator specification without braces */
loclist_opt:
loclist { $$ = $1; } |
/* empty */ { $$ = NULL; };
-/* loclist order matters, must use right recursion */
+/*
+ * loclist order matters, must use right recursion
+ * XXX wot?
+ */
+
+/* list of locator definitions */
loclist:
locdef ',' loclist { $$ = $1; app($1, $3); } |
locdef { $$ = $1; };
Home |
Main Index |
Thread Index |
Old Index