From 04d858e047f9279a698ef3f96e9add07a4a88ca2 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 20 May 2012 19:00:04 -0300 Subject: [PATCH] b2/: export field hierarchy and substitution rules from lang.y --- b2/lang.h | 7 +++++++ b2/lang.y | 24 ++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/b2/lang.h b/b2/lang.h index b3340e6..c5c2c2a 100644 --- a/b2/lang.h +++ b/b2/lang.h @@ -13,6 +13,13 @@ #ifndef LANG_H #define LANG_H +#include "chr.h" +#include "subst.h" + + +extern struct action hierarchy; +extern struct subst *substitutions; + void parse_hierarchy(const char *name); void parse_characteristics(const char *name); void parse_inventory(const char *name); diff --git a/b2/lang.y b/b2/lang.y index a4c6984..15743f3 100644 --- a/b2/lang.y +++ b/b2/lang.y @@ -24,7 +24,9 @@ #include "y.tab.h" -static struct action hierarchy; +struct action hierarchy; +struct subst *substitutions = NULL; + static struct currency *curr; @@ -100,23 +102,29 @@ static const struct field *top_field(void) %type /*rules*/ opt_rule rule opt_fields fields field %type selectors %type conditions condition -%type opt_wildcard action +%type hierarchy opt_wildcard action %type part inventory_item %type param params %type prices price %type stock %type providers provider -%type block opt_block +%type substitutions block opt_block %% all: START_HIERARCHY hierarchy + { + hierarchy = $2; + } | START_CHAR characteristics | START_INVENTORY inventory | START_EXCHANGE exchange | START_PROVIDERS providers | START_SUBST substitutions + { + substitutions = $2; + } ; @@ -125,9 +133,12 @@ all: hierarchy: nameset hierarchy + { + $$ = $2; + } | action { - hierarchy = $1; + $$ = $1; field_dump(stderr, $1.fields); field_dump(stderr, $1.rules); } @@ -566,8 +577,9 @@ provider: substitutions: block { - subst_finalize($1); - subst_dump(stderr, $1); + $$ = $1; + subst_finalize($$); + subst_dump(stderr, $$); } ;