Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/config Sort productions in grammar. No functional ch...



details:   https://anonhg.NetBSD.org/src/rev/8e78dec1b581
branches:  trunk
changeset: 777964:8e78dec1b581
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Mar 11 02:43:33 2012 +0000

description:
Sort productions in grammar. No functional change.

diffstat:

 usr.bin/config/gram.y |  537 +++++++++++++++++++++++++------------------------
 1 files changed, 272 insertions(+), 265 deletions(-)

diffs (truncated from 623 to 300 lines):

diff -r a08c60bb903e -r 8e78dec1b581 usr.bin/config/gram.y
--- a/usr.bin/config/gram.y     Sun Mar 11 02:21:04 2012 +0000
+++ b/usr.bin/config/gram.y     Sun Mar 11 02:43:33 2012 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: gram.y,v 1.28 2012/03/11 02:21:04 dholland Exp $       */
+/*     $NetBSD: gram.y,v 1.29 2012/03/11 02:43:33 dholland Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -228,133 +228,6 @@
 /************************************************************/
 
 /*
- * 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:
-         /* empty */                   { $$ = -1; }
-       | BLOCK NUMBER                  { $$ = $2.val; }
-;
-
-/* char 55 */
-device_major_char:
-         /* empty */                   { $$ = -1; }
-       | CHAR NUMBER                   { $$ = $2.val; }
-;
-
-/*
- * order of options is important, must use right recursion
- *
- * dholland 20120310: wut?
- */
-
-/* file options: optional expression of config elements */
-fopts:
-         /* empty */                   { $$ = NULL; }
-       | fexpr                         { $$ = $1; }
-;
-
-/* expression of config elements */
-/* XXX this should use a real expression grammar */
-fexpr:
-         fatom                         { $$ = $1; }
-       | '!' fatom                     { $$ = fx_not($2); }
-       | fexpr '&' fexpr               { $$ = fx_and($1, $3); }
-       | 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:
-         /* empty */                   { $$ = 0; }
-       | fflgs fflag                   { $$ = $1 | $2; }
-;
-
-/* one flag for a file */
-fflag:
-         NEEDS_COUNT                   { $$ = FI_NEEDSCOUNT; }
-       | NEEDS_FLAG                    { $$ = FI_NEEDSFLAG; }
-;
-
-/* device node specification */
-devnodes:
-         /* empty */                   { $$ = new_s("DEVNODE_DONTBOTHER"); }
-       | devnodetype ',' devnodeflags  { $$ = nvcat($1, $3); }
-       | devnodetype                   { $$ = $1; }
-;
-
-/* device nodes without flags */
-devnodetype:
-         SINGLE                        { $$ = new_s("DEVNODE_SINGLE"); }
-       | VECTOR '=' devnode_dims  { $$ = nvcat(new_s("DEVNODE_VECTOR"), $3); }
-;
-
-/* dimensions (?) */
-devnode_dims:
-         NUMBER                        { $$ = new_i($1.val); }
-       | NUMBER ':' NUMBER             {
-               struct nvlist *__nv1, *__nv2;
-
-               __nv1 = new_i($1.val);
-               __nv2 = new_i($3.val);
-               $$ = nvcat(__nv1, __nv2);
-         }
-;
-
-/* flags for device nodes */
-devnodeflags:
-       LINKZERO                        { $$ = new_s("DEVNODE_FLAG_LINKZERO");}
-;
-
-/* zero or more flags for an object file */
-oflgs:
-         /* empty */                   { $$ = 0; }
-       | oflgs oflag                   { $$ = $1 | $2; }
-;
-
-/* a single flag for an object file */
-oflag:
-       NEEDS_FLAG                      { $$ = OI_NEEDSFLAG; }
-;
-
-/* extra compile directive for a source file */
-rule:
-         /* empty */                   { $$ = NULL; }
-       | COMPILE_WITH stringvalue      { $$ = $2; }
-;
-
-/* prefix delimiter */
-prefix:
-         PREFIX filename               { prefix_push($2); }
-       | PREFIX                        { prefix_pop(); }
-;
-
-/************************************************************/
-
-/*
  * The machine definitions grammar.
  */
 
@@ -409,16 +282,103 @@
        | VERSION NUMBER                { setversion($2.val); }
 ;
 
-/* list of places to attach: attach blah at ... */
-atlist:
-         atname                        { $$ = new_n($1); }
-       | atlist ',' atname             { $$ = new_nx($3, $1); }
+/* source file: file foo/bar.c bar|baz needs-flag compile-with blah */
+file:
+       XFILE filename fopts fflgs rule { addfile($2, $3, $4, $5); }
+;
+
+/* file options: optional expression of config elements */
+fopts:
+         /* empty */                   { $$ = NULL; }
+       | fexpr                         { $$ = $1; }
+;
+
+/* zero or more flags for a file */
+fflgs:
+         /* empty */                   { $$ = 0; }
+       | fflgs fflag                   { $$ = $1 | $2; }
+;
+
+/* one flag for a file */
+fflag:
+         NEEDS_COUNT                   { $$ = FI_NEEDSCOUNT; }
+       | NEEDS_FLAG                    { $$ = FI_NEEDSFLAG; }
+;
+
+/* extra compile directive for a source file */
+rule:
+         /* empty */                   { $$ = NULL; }
+       | COMPILE_WITH stringvalue      { $$ = $2; }
+;
+
+/* object file: object zot.o foo|zot needs-flag */
+object:
+       XOBJECT filename fopts oflgs    { addobject($2, $3, $4); }
+;
+
+/* zero or more flags for an object file */
+oflgs:
+         /* empty */                   { $$ = 0; }
+       | oflgs oflag                   { $$ = $1 | $2; }
+;
+
+/* a single flag for an object file */
+oflag:
+       NEEDS_FLAG                      { $$ = OI_NEEDSFLAG; }
 ;
 
-/* a place to attach a device */
-atname:
-         WORD                          { $$ = $1; }
-       | ROOT                          { $$ = NULL; }
+/* device major declaration */
+device_major:
+       DEVICE_MAJOR WORD device_major_char device_major_block fopts devnodes
+                                       { adddevm($2, $3, $4, $5, $6); }
+;
+
+/* char 55 */
+device_major_char:
+         /* empty */                   { $$ = -1; }
+       | CHAR NUMBER                   { $$ = $2.val; }
+;
+
+/* block 33 */
+device_major_block:
+         /* empty */                   { $$ = -1; }
+       | BLOCK NUMBER                  { $$ = $2.val; }
+;
+
+/* device node specification */
+devnodes:
+         /* empty */                   { $$ = new_s("DEVNODE_DONTBOTHER"); }
+       | devnodetype ',' devnodeflags  { $$ = nvcat($1, $3); }
+       | devnodetype                   { $$ = $1; }
+;
+
+/* device nodes without flags */
+devnodetype:
+         SINGLE                        { $$ = new_s("DEVNODE_SINGLE"); }
+       | VECTOR '=' devnode_dims  { $$ = nvcat(new_s("DEVNODE_VECTOR"), $3); }
+;
+
+/* dimensions (?) */
+devnode_dims:
+         NUMBER                        { $$ = new_i($1.val); }
+       | NUMBER ':' NUMBER             {
+               struct nvlist *__nv1, *__nv2;
+
+               __nv1 = new_i($1.val);
+               __nv2 = new_i($3.val);
+               $$ = nvcat(__nv1, __nv2);
+         }
+;
+
+/* flags for device nodes */
+devnodeflags:
+       LINKZERO                        { $$ = new_s("DEVNODE_FLAG_LINKZERO");}
+;
+
+/* prefix delimiter */
+prefix:
+         PREFIX filename               { prefix_push($2); }
+       | PREFIX                        { prefix_pop(); }
 ;
 
 /* one or more file system names */
@@ -432,56 +392,6 @@
        WORD                            { $$ = $1; }
 ;
 
-/* option dependencies (read as "defopt deps") which are optional */
-defoptdeps:
-         /* empty */                   { $$ = NULL; }
-       | ':' optdeps                   { $$ = $2; }
-;
-
-/* a list of option dependencies */
-optdeps:
-         optdep                        { $$ = new_n($1); }
-       | optdeps ',' optdep            { $$ = new_nx($3, $1); }
-;
-
-/* one option dependence */
-optdep:
-       WORD                            { $$ = $1; }
-;
-
-/* one or more defined options */
-defopts:
-         defopt                        { $$ = $1; }
-       | defopts defopt                { $$ = nvcat($2, $1); }
-;
-
-/* one defined option */
-defopt:
-         WORD                          { $$ = new_n($1); }
-       | WORD '=' value                { $$ = new_ns($1, $3); }
-       | WORD COLONEQ value            {
-               struct nvlist *__nv = new_n($1);
-
-               $$ = new_nsx("", $3, __nv);
-         }
-       | WORD '=' value COLONEQ value  {
-               struct nvlist *__nv = new_n($1);
-
-               $$ = new_nsx("", $5, __nv);
-         }
-;
-
-/* device name */



Home | Main Index | Thread Index | Old Index