mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-05 07:32:49 +02:00
103 lines
1.6 KiB
C
103 lines
1.6 KiB
C
/*
|
|
* chr.h - Part characteristics
|
|
*
|
|
* Copyright 2012 by Werner Almesberger
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*/
|
|
|
|
|
|
#include "util.h"
|
|
#include "param.h"
|
|
#include "chr.h"
|
|
|
|
|
|
struct condition {
|
|
struct value value;
|
|
enum relop relop;
|
|
struct condition *next;
|
|
};
|
|
|
|
struct selector {
|
|
struct condition *cond;
|
|
struct selector *next;
|
|
};
|
|
|
|
struct field {
|
|
const char *name;
|
|
const struct format *fmt;
|
|
struct field *mark;
|
|
struct selector *sel;
|
|
struct field *next;
|
|
};
|
|
|
|
static struct field *fields = NULL, *curr_field = NULL, *mark = NULL;
|
|
|
|
|
|
const struct format *field_find(const char *name)
|
|
{
|
|
const struct field *f;
|
|
|
|
for (f = fields; f; f = f->next)
|
|
if (f->name == name)
|
|
return f->fmt;
|
|
return NULL;
|
|
}
|
|
|
|
|
|
void field_add(const char *name, const struct format *fmt)
|
|
{
|
|
struct field *field;
|
|
|
|
if (field_find(name))
|
|
yyerrorf("duplicate field \"%s\"", name);
|
|
field = alloc_type(struct field);
|
|
field->name = name;
|
|
field->fmt = fmt;
|
|
field->mark = (void *) 1; /* poison */
|
|
field->sel = NULL;
|
|
if (curr_field)
|
|
curr_field->next = field;
|
|
else
|
|
fields = field;
|
|
curr_field = field;
|
|
}
|
|
|
|
|
|
void field_mark(void)
|
|
{
|
|
if (mark)
|
|
mark->mark = curr_field;
|
|
mark = curr_field;
|
|
}
|
|
|
|
|
|
void field_release(void)
|
|
{
|
|
curr_field = mark;
|
|
if (curr_field)
|
|
mark = curr_field->mark;
|
|
}
|
|
|
|
|
|
void field_add_selector(enum relop relop, const char *word)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
void field_more_selectors(void)
|
|
{
|
|
if (curr_field->fmt->ops != ¶m_ops_set)
|
|
;//yyerrorf("
|
|
}
|
|
|
|
|
|
void field_add_wildcard(void)
|
|
{
|
|
}
|
|
|