Current-Users archive

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

Re: A couple of config(1) questions



On Sun, 10 May 2015, Michael van Elst wrote:

Just how complex can these expressions be?  For example, can I use
	(a | b) & (x | y | z)
with parentheses?


config uses a yacc grammar (src/usr.bin/config/gram.y):

<snip>

/* zero or more flags for a file */
fflags:
         /* empty */                   { $$ = 0; }
       | fflags 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; }
;


So it's the options that can be an expression. [rule] is
the keyword 'compile-with' followed by a string holding
a compiler command that is used in the generated Makefile.
Without a rule, config generates the rule ${NORMAL_<upper-case-suffix>}
I.e. ${NORMAL_C} for a C file. That variable is defined in
sys/conf/Makefile.kern.inc.

Kewl - thanks for helping me figure out how to parse yacc's grammar!


The condexpr used for fopts can handle the operators |,& and
! (or,and,not) and allows parenthesis, i.e. (a | b) & (x | y | z)
works fine. But the parser does not handle negations of sub-expressions
like !( a | b ).

Yeah, what I wanted does indeed work.

<snip>

Question 2:  does config(1) support '\' at the end of a physical line to
indicate line continuation?  (If the complex boolean expression above is
supported, I'm likely to have a longer-than-80-char command!)

The config parser uses a different syntax to handle continuation
lines. From config(9):

    Each device definition file consists of a list of statements, typically
    one per line.  Comments may be inserted anywhere using the ``#''
    character, and any line that begins with white space continues the
    previous line.

Thanks - I missed that while reading the man page.


-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index