1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-29 23:27:31 +02:00

b2/: export field hierarchy and substitution rules from lang.y

This commit is contained in:
Werner Almesberger 2012-05-20 19:00:04 -03:00
parent fd14c5200a
commit 04d858e047
2 changed files with 25 additions and 6 deletions

View File

@ -13,6 +13,13 @@
#ifndef LANG_H #ifndef LANG_H
#define 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_hierarchy(const char *name);
void parse_characteristics(const char *name); void parse_characteristics(const char *name);
void parse_inventory(const char *name); void parse_inventory(const char *name);

View File

@ -24,7 +24,9 @@
#include "y.tab.h" #include "y.tab.h"
static struct action hierarchy; struct action hierarchy;
struct subst *substitutions = NULL;
static struct currency *curr; static struct currency *curr;
@ -100,23 +102,29 @@ static const struct field *top_field(void)
%type <field> /*rules*/ opt_rule rule opt_fields fields field %type <field> /*rules*/ opt_rule rule opt_fields fields field
%type <sel> selectors %type <sel> selectors
%type <cond> conditions condition %type <cond> conditions condition
%type <act> opt_wildcard action %type <act> hierarchy opt_wildcard action
%type <part> part inventory_item %type <part> part inventory_item
%type <param> param params %type <param> param params
%type <price> prices price %type <price> prices price
%type <stock> stock %type <stock> stock
%type <prov> providers provider %type <prov> providers provider
%type <subst> block opt_block %type <subst> substitutions block opt_block
%% %%
all: all:
START_HIERARCHY hierarchy START_HIERARCHY hierarchy
{
hierarchy = $2;
}
| START_CHAR characteristics | START_CHAR characteristics
| START_INVENTORY inventory | START_INVENTORY inventory
| START_EXCHANGE exchange | START_EXCHANGE exchange
| START_PROVIDERS providers | START_PROVIDERS providers
| START_SUBST substitutions | START_SUBST substitutions
{
substitutions = $2;
}
; ;
@ -125,9 +133,12 @@ all:
hierarchy: hierarchy:
nameset hierarchy nameset hierarchy
{
$$ = $2;
}
| action | action
{ {
hierarchy = $1; $$ = $1;
field_dump(stderr, $1.fields); field_dump(stderr, $1.fields);
field_dump(stderr, $1.rules); field_dump(stderr, $1.rules);
} }
@ -566,8 +577,9 @@ provider:
substitutions: substitutions:
block block
{ {
subst_finalize($1); $$ = $1;
subst_dump(stderr, $1); subst_finalize($$);
subst_dump(stderr, $$);
} }
; ;