From 1394c6b61c24f09116643c4dfb7b6c73e6953cec Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 28 Apr 2012 23:30:50 -0300 Subject: [PATCH] b2/: make top-level hierarchy item an action, not just a rule This allows the definition of optional global fields. For now, we (ab)use this for FP (footprint). --- b2/HIERARCHY | 5 +++-- b2/db.c | 5 +++-- b2/db.h | 2 +- b2/lang.y | 9 +++++---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/b2/HIERARCHY b/b2/HIERARCHY index bf1a47a..54567ae 100644 --- a/b2/HIERARCHY +++ b/b2/HIERARCHY @@ -5,8 +5,9 @@ = R = D { - R: { R=#R TOL=%R FP=* }; + R: { R=#R TOL=%R }; C: { C=#F TOL=%C V=#V }; L: { L=#H TOL=%L I=#A }; D: { C=#F } @@ -15,4 +16,4 @@ T= { Z: { V=#V I=#A }; *: { Vf=#V Vr=#V I=#A }; }; -} +}; diff --git a/b2/db.c b/b2/db.c index 4bf259f..ad1afc4 100644 --- a/b2/db.c +++ b/b2/db.c @@ -140,14 +140,15 @@ static void convert_params(struct param **params, } -void part_finalize(struct part *part, const struct field *field) +void part_finalize(struct part *part, const struct action *act) { struct param *param = part->param; struct param **res = &part->param; struct param *next; part->param = NULL; - convert_params(¶m, field, &res); + convert_params(¶m, act->fields, &res); + convert_params(¶m, act->rules, &res); while (param) { yywarnf("extra parameter: %s", param->u.name); next = param->next; diff --git a/b2/db.h b/b2/db.h index 4648442..7125320 100644 --- a/b2/db.h +++ b/b2/db.h @@ -65,7 +65,7 @@ struct part { struct part *part_lookup(const char *domain, const char *name); struct part *part_add(const char *domain, const char *name); void part_alias(struct part *a, struct part *b); -void part_finalize(struct part *part, const struct field *field); +void part_finalize(struct part *part, const struct action *act); void part_dump(FILE *file, const struct part *part); #endif /* !DB_H */ diff --git a/b2/lang.y b/b2/lang.y index 5ed8f57..7f39cc1 100644 --- a/b2/lang.y +++ b/b2/lang.y @@ -23,7 +23,7 @@ #include "y.tab.h" -static const struct field *hierarchy; +static struct action hierarchy; static struct field_stack { const struct field *field; @@ -101,10 +101,11 @@ all: hierarchy: nameset hierarchy - | rule + | action { hierarchy = $1; - field_dump(stderr, $1); + field_dump(stderr, $1.fields); + field_dump(stderr, $1.rules); } ; @@ -352,7 +353,7 @@ characteristics: | TOK_NL | part characteristics { - part_finalize($1, hierarchy); + part_finalize($1, &hierarchy); part_dump(stderr, $1); } ;