aboutsummaryrefslogtreecommitdiff
path: root/inc/term.h
blob: 4cbc0b2497bc952eaaa4240780585731f20cac70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) 2024, Marvin Borner <dev@marvinborner.de>
// SPDX-License-Identifier: MIT

#ifndef BLOCADE_TERM_H
#define BLOCADE_TERM_H

#include <stddef.h>

typedef enum { INV, ABS, APP, VAR, REF } term_type;

struct term {
	term_type type;
	union {
		struct {
			struct term *term;
		} abs;
		struct {
			struct term *lhs;
			struct term *rhs;
		} app;
		struct {
			int index;
		} var;
		struct {
			size_t index;
		} ref;
	} u;
	unsigned int meta; // arbitrary field for targets
};

struct term *new_term(term_type type);
void free_term(struct term *term);

#endif