Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/config Write out the expression grammar for dependen...
details: https://anonhg.NetBSD.org/src/rev/c37863df7b8a
branches: trunk
changeset: 777965:c37863df7b8a
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Mar 11 02:56:25 2012 +0000
description:
Write out the expression grammar for dependency constraints instead of
using precedence rules. Precedence rules (besides being a hack) often
lead to unexpected/unwanted behavior in corner cases.
diffstat:
usr.bin/config/gram.y | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diffs (55 lines):
diff -r 8e78dec1b581 -r c37863df7b8a usr.bin/config/gram.y
--- a/usr.bin/config/gram.y Sun Mar 11 02:43:33 2012 +0000
+++ b/usr.bin/config/gram.y Sun Mar 11 02:56:25 2012 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: gram.y,v 1.29 2012/03/11 02:43:33 dholland Exp $ */
+/* $NetBSD: gram.y,v 1.30 2012/03/11 02:56:25 dholland Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -123,10 +123,8 @@
%token <str> PATHNAME QSTRING WORD EMPTYSTRING
%token ENDDEFS
-%left '|'
-%left '&'
-
%type <list> fopts fexpr fatom
+%type <list> f_or_expr f_and_expr f_prefix_expr f_base_expr
%type <str> fs_spec
%type <val> fflgs fflag oflgs oflag
%type <str> rule
@@ -755,12 +753,29 @@
*/
/* expression of config elements */
-/* XXX this should use a real expression grammar */
fexpr:
+ f_or_expr
+;
+
+f_or_expr:
+ f_and_expr
+ | f_or_expr '|' f_and_expr { $$ = fx_or($1, $3); }
+;
+
+f_and_expr:
+ f_prefix_expr
+ | f_and_expr '&' f_prefix_expr { $$ = fx_and($1, $3); }
+;
+
+f_prefix_expr:
+ f_base_expr
+/* XXX notyet - need to strengthen downstream first */
+/* | '!' f_prefix_expr { $$ = fx_not($2); } */
+;
+
+f_base_expr:
fatom { $$ = $1; }
| '!' fatom { $$ = fx_not($2); }
- | fexpr '&' fexpr { $$ = fx_and($1, $3); }
- | fexpr '|' fexpr { $$ = fx_or($1, $3); }
| '(' fexpr ')' { $$ = $2; }
;
Home |
Main Index |
Thread Index |
Old Index