mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-04 22:58:26 +02:00
separate dumping of hierchy rules from dumping of fields
With only one function, top-level fields definitions were printed in a style as if they were rules and not fields.
This commit is contained in:
parent
e943baf1c3
commit
b6a4a80652
44
b2/chr.c
44
b2/chr.c
@ -97,7 +97,7 @@ void field_finalize(struct field *field)
|
||||
#define INDENT 8
|
||||
|
||||
|
||||
static void dump_fields(FILE *file, const struct field *field, int level);
|
||||
static void dump_rules(FILE *file, const struct field *field, int level);
|
||||
|
||||
|
||||
static void dump_set_decl(FILE *file, const struct names *first_name)
|
||||
@ -127,23 +127,16 @@ static void dump_field_decl(FILE *file, const struct field *field)
|
||||
|
||||
static void dump_action(FILE *file, const struct action *act, int level)
|
||||
{
|
||||
const struct field *field;
|
||||
|
||||
if (act->fields) {
|
||||
fprintf(file, " {");
|
||||
for (field = act->fields; field; field = field->next) {
|
||||
fprintf(file, " %s=", field->name);
|
||||
dump_field_decl(file, field);
|
||||
}
|
||||
fprintf(file, " }\n");
|
||||
} else {
|
||||
fprintf(file, "\n");
|
||||
fprintf(file, " ");
|
||||
fields_dump(file, act->fields);
|
||||
}
|
||||
dump_fields(file, act->rules, level+1);
|
||||
fprintf(file, "\n");
|
||||
dump_rules(file, act->rules, level+1);
|
||||
}
|
||||
|
||||
|
||||
static void dump_one_field(FILE *file, const struct field *field, int level)
|
||||
static void dump_one_rule(FILE *file, const struct field *field, int level)
|
||||
{
|
||||
const struct selector *sel;
|
||||
const struct condition *cond;
|
||||
@ -162,7 +155,7 @@ static void dump_one_field(FILE *file, const struct field *field, int level)
|
||||
dump_relop(file, cond->relop);
|
||||
dump(file, field->fmt, &cond->value);
|
||||
}
|
||||
fprintf(file, ": ");
|
||||
fprintf(file, ":");
|
||||
dump_action(file, &sel->act, level);
|
||||
}
|
||||
if (field->any.fields || field->any.rules) {
|
||||
@ -173,16 +166,31 @@ static void dump_one_field(FILE *file, const struct field *field, int level)
|
||||
}
|
||||
|
||||
|
||||
static void dump_fields(FILE *file, const struct field *field, int level)
|
||||
void fields_dump(FILE *file, const struct field *fields)
|
||||
{
|
||||
const struct field *f;
|
||||
|
||||
if (!fields)
|
||||
return;
|
||||
fprintf(file, "{ ");
|
||||
for (f = fields; f; f = f->next) {
|
||||
fprintf(file, "%s%s=", f == fields ? "" : " ", f->name);
|
||||
dump_field_decl(file, f);
|
||||
}
|
||||
fprintf(file, " }");
|
||||
}
|
||||
|
||||
|
||||
static void dump_rules(FILE *file, const struct field *field, int level)
|
||||
{
|
||||
while (field) {
|
||||
dump_one_field(file, field, level);
|
||||
dump_one_rule(file, field, level);
|
||||
field = field->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void field_dump(FILE *file, const struct field *field)
|
||||
void rules_dump(FILE *file, const struct field *field)
|
||||
{
|
||||
dump_fields(file, field, 0);
|
||||
dump_rules(file, field, 0);
|
||||
}
|
||||
|
3
b2/chr.h
3
b2/chr.h
@ -53,6 +53,7 @@ struct field *new_field(const char *name, const struct format *fmt,
|
||||
struct selector *new_selector(void);
|
||||
struct condition *new_condition(enum relop relop, const char *word);
|
||||
void field_finalize(struct field *field);
|
||||
void field_dump(FILE *file, const struct field *field);
|
||||
void fields_dump(FILE *file, const struct field *field);
|
||||
void rules_dump(FILE *file, const struct field *field);
|
||||
|
||||
#endif /* !CHR_H */
|
||||
|
Loading…
Reference in New Issue
Block a user