Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/config Reformat according to (my) basic standards fo...



details:   https://anonhg.NetBSD.org/src/rev/66819c8e6550
branches:  trunk
changeset: 777958:66819c8e6550
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Mar 11 00:57:44 2012 +0000

description:
Reformat according to (my) basic standards for yacc grammars.
No functional change.

diffstat:

 usr.bin/config/gram.y |  589 +++++++++++++++++++++++++++++--------------------
 1 files changed, 344 insertions(+), 245 deletions(-)

diffs (truncated from 898 to 300 lines):

diff -r d7b50ab097ef -r 66819c8e6550 usr.bin/config/gram.y
--- a/usr.bin/config/gram.y     Sun Mar 11 00:34:45 2012 +0000
+++ b/usr.bin/config/gram.y     Sun Mar 11 00:57:44 2012 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: gram.y,v 1.25 2012/03/11 00:14:20 dholland Exp $       */
+/*     $NetBSD: gram.y,v 1.26 2012/03/11 00:57:44 dholland Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -195,38 +195,43 @@
 /* Complete configuration. */
 Configuration:
        topthings
-       machine_spec
-       dev_defs ENDDEFS
-                                       { check_maxpart(); check_version(); }
-       specs;
+               machine_spec dev_defs ENDDEFS
+               { check_maxpart(); check_version(); }
+               specs
+;
 
 /* Sequence of zero or more topthings. */
 topthings:
-       topthings topthing |
-       /* empty */;
+         /* empty */
+       | topthings topthing
+;
 
 /* Directory specification. */
 topthing:
-       SOURCE filename '\n'            { if (!srcdir) srcdir = $2; } |
-       BUILD  filename '\n'            { if (!builddir) builddir = $2; } |
-       '\n';
+         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"); };
+         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; };
+         /* empty */                   { $$ = NULL; }
+       | subarches
+;
 
 /* Subarches declaration. */
 subarches:
-       subarches WORD                  { $$ = new_nx($2, $1); } |
-       WORD                            { $$ = new_n($1); };
+         subarches WORD                { $$ = new_nx($2, $1); }
+       | WORD                          { $$ = new_n($1); }
+;
 
 /************************************************************/
 
@@ -237,25 +242,31 @@
 
 /* source file: file foo/bar.c bar|baz needs-flag compile-with blah */
 file:
-       XFILE filename fopts fflgs rule { addfile($2, $3, $4, $5); };
+       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); };
+       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); };
+                                       { adddevm($2, $3, $4, $5, $6); }
+;
+
 /* block 33 */
 device_major_block:
-       BLOCK NUMBER                    { $$ = $2.val; } |
-       /* empty */                     { $$ = -1; };
+         /* empty */                   { $$ = -1; }
+       | BLOCK NUMBER                  { $$ = $2.val; }
+;
 
 /* char 55 */
 device_major_char:
-       CHAR NUMBER                     { $$ = $2.val; } |
-       /* empty */                     { $$ = -1; };
+         /* empty */                   { $$ = -1; }
+       | CHAR NUMBER                   { $$ = $2.val; }
+;
 
 /*
  * order of options is important, must use right recursion
@@ -265,73 +276,89 @@
 
 /* file options: optional expression of config elements */
 fopts:
-       fexpr                           { $$ = $1; } |
-       /* empty */                     { $$ = NULL; };
+         /* 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; };
+         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); };
+       WORD                            { $$ = fx_atom($1); }
+;
 
 /* zero or more flags for a file */
 fflgs:
-       fflgs fflag                     { $$ = $1 | $2; } |
-       /* empty */                     { $$ = 0; };
+         /* empty */                   { $$ = 0; }
+       | fflgs fflag                   { $$ = $1 | $2; }
+;
 
 /* one flag for a file */
 fflag:
-       NEEDS_COUNT                     { $$ = FI_NEEDSCOUNT; } |
-       NEEDS_FLAG                      { $$ = FI_NEEDSFLAG; };
+         NEEDS_COUNT                   { $$ = FI_NEEDSCOUNT; }
+       | NEEDS_FLAG                    { $$ = FI_NEEDSFLAG; }
+;
 
 /* device node specification */
 devnodes:
-       devnodetype ',' devnodeflags    { $$ = nvcat($1, $3); } |
-       devnodetype                     { $$ = $1; } |
-       /* empty */                     { $$ = new_s("DEVNODE_DONTBOTHER"); };
+         /* 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); };
+         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);
-                                         __nv2 = new_i($3.val);
-                                         $$ = nvcat(__nv1, __nv2); } |
-       NUMBER                          { $$ = new_i($1.val); }
+         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");};
+       LINKZERO                        { $$ = new_s("DEVNODE_FLAG_LINKZERO");}
+;
 
 /* zero or more flags for an object file */
 oflgs:
-       oflgs oflag                     { $$ = $1 | $2; } |
-       /* empty */                     { $$ = 0; };
+         /* empty */                   { $$ = 0; }
+       | oflgs oflag                   { $$ = $1 | $2; }
+;
 
 /* a single flag for an object file */
 oflag:
-       NEEDS_FLAG                      { $$ = OI_NEEDSFLAG; };
+       NEEDS_FLAG                      { $$ = OI_NEEDSFLAG; }
+;
 
 /* extra compile directive for a source file */
 rule:
-       COMPILE_WITH stringvalue        { $$ = $2; } |
-       /* empty */                     { $$ = NULL; };
+         /* empty */                   { $$ = NULL; }
+       | COMPILE_WITH stringvalue      { $$ = $2; }
+;
 
 /* prefix delimiter */
 prefix:
-       PREFIX filename                 { prefix_push($2); } |
-       PREFIX                          { prefix_pop(); };
+         PREFIX filename               { prefix_push($2); }
+       | PREFIX                        { prefix_pop(); }
+;
 
 /************************************************************/
 
@@ -341,122 +368,139 @@
 
 /* Complete definition part: the contents of all files.* files. */
 dev_defs:
-       dev_defs dev_def |
-       dev_defs ENDFILE                { enddefs(); checkfiles(); } |
-       /* empty */;
+         /* empty */
+       | dev_defs dev_def
+       | dev_defs ENDFILE              { enddefs(); checkfiles(); }
+;
 
 /* A single definition, or a blank line. Trap errors. */
 dev_def:
-       one_def '\n'                    { adepth = 0; } |
-       '\n' |
-       error '\n'                      { cleanup(); };
+         '\n'
+       | one_def '\n'                  { adepth = 0; }
+       | error '\n'                    { cleanup(); }
+;
 
 /* A single definition. */
 one_def:
-       file |
-       object |
-       device_major                    { do_devsw = 1; } |
-       prefix |
-       DEVCLASS WORD                   { (void)defattr($2, NULL, NULL, 1); } |
-       DEFFS deffses defoptdeps        { deffilesystem($2, $3); } |
-       DEFINE WORD interface_opt attrs_opt
-                                       { (void)defattr($2, $3, $4, 0); } |
-       DEFOPT optfile_opt defopts defoptdeps
-                                       { defoption($2, $3, $4); } |
-       DEFFLAG optfile_opt defopts defoptdeps
-                                       { defflag($2, $3, $4, 0); } |
-       OBSOLETE DEFFLAG optfile_opt defopts
-                                       { defflag($3, $4, NULL, 1); } |
-       DEFPARAM optfile_opt defopts defoptdeps
-                                       { defparam($2, $3, $4, 0); } |
-       OBSOLETE DEFPARAM optfile_opt defopts
-                                       { defparam($3, $4, NULL, 1); } |
-       DEVICE devbase interface_opt attrs_opt
-                                       { defdev($2, $3, $4, 0); } |
-       ATTACH devbase AT atlist devattach_opt attrs_opt
-                                       { defdevattach($5, $2, $4, $6); } |
-       MAXPARTITIONS NUMBER            { maxpartitions = $2.val; } |
-       MAXUSERS NUMBER NUMBER NUMBER   { setdefmaxusers($2.val, $3.val, $4.val); } |
-       MAKEOPTIONS condmkopt_list |
+         file
+       | object
+       | device_major                  { do_devsw = 1; }
+       | prefix
+       | DEVCLASS WORD                 { (void)defattr($2, NULL, NULL, 1); }
+       | DEFFS deffses defoptdeps      { deffilesystem($2, $3); }
+       | DEFINE WORD interface_opt attrs_opt
+                                       { (void)defattr($2, $3, $4, 0); }
+       | DEFOPT optfile_opt defopts defoptdeps
+                                       { defoption($2, $3, $4); }
+       | DEFFLAG optfile_opt defopts defoptdeps
+                                       { defflag($2, $3, $4, 0); }
+       | OBSOLETE DEFFLAG optfile_opt defopts
+                                       { defflag($3, $4, NULL, 1); }
+       | DEFPARAM optfile_opt defopts defoptdeps
+                                       { defparam($2, $3, $4, 0); }
+       | OBSOLETE DEFPARAM optfile_opt defopts
+                                       { defparam($3, $4, NULL, 1); }
+       | DEVICE devbase interface_opt attrs_opt
+                                       { defdev($2, $3, $4, 0); }
+       | ATTACH devbase AT atlist devattach_opt attrs_opt



Home | Main Index | Thread Index | Old Index