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, $$); } ;