1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-16 21:50:38 +02:00

b2/lang.y: don't pop fields from the stack before also handling the rule

This commit is contained in:
Werner Almesberger 2012-05-31 15:33:19 -03:00
parent 4943519eb3
commit a892b63d55

View File

@ -50,14 +50,18 @@ static void push_field(const struct field *field)
} }
static void pop_field(void) static void pop_fields(const struct field *last)
{ {
struct field_stack *entry; struct field_stack *entry;
const struct field *popped;
do {
assert(field_stack); assert(field_stack);
entry = field_stack; entry = field_stack;
popped = entry->field;
field_stack = entry->next; field_stack = entry->next;
free(entry); free(entry);
} while (popped != last);
} }
@ -241,7 +245,7 @@ rule:
$$->any = $5; $$->any = $5;
$$->next = NULL; $$->next = NULL;
field_finalize($$); field_finalize($$);
pop_field(); pop_fields($$);
} }
; ;
@ -290,13 +294,14 @@ opt_wildcard:
action: action:
{ {
$<field>$ = (struct field *) top_field();
push_field(top_field()); push_field(top_field());
} }
opt_fields opt_rule ';' opt_fields opt_rule ';'
{ {
$$.fields = $2; $$.fields = $2;
$$.rules = $3; $$.rules = $3;
pop_field(); pop_fields($<field>1);
} }
; ;
@ -349,14 +354,13 @@ fields:
} }
| field | field
{ {
$1->prev = top_field();
push_field($1); push_field($1);
} }
fields fields
{ {
$$ = $1; $$ = $1;
$$->next = $3; $$->next = $3;
pop_field();
$$->prev = top_field();
if ($3) if ($3)
$3->prev = $1; $3->prev = $1;
} }