/*
 * 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.
 */


#ifndef CHR_H
#define	CHR_H

#include <stdio.h>

#include "param.h"


struct field;

struct action {
	struct field *fields;
	struct field *rules;
};

struct condition {
	struct value value;
	enum relop relop;
	struct condition *next;
};

struct selector {
	struct condition *cond;
	struct action act;
	struct selector *next;
};

struct field {
	const char *name;
	const struct format *fmt;
	struct selector *sel;
	struct action any;
	struct field *next;
	const struct field *prev;
};


const struct format *field_find(const char *name, const struct field *tail);
struct field *new_field(const char *name, const struct format *fmt,
    const struct field *prev);
struct selector *new_selector(void);
struct condition *new_condition(enum relop relop, const char *word);
void field_finalize(struct field *field);
void fields_dump(FILE *file, const struct field *field);
void rules_dump(FILE *file, const struct field *field);

#endif /* !CHR_H */