aboutsummaryrefslogtreecommitdiff
path: root/ibpctypes.h
blob: c1ba6327b01ae783f1f7597e77708f9d7de382a8 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * Types for IB Pseudocode
 *
 * Copyright (C) 2024  Runxi Yu <https://runxiyu.org>
 * SPDX-License-Identifier: AGPL-3.0-or-later
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#pragma once

#include <sys/types.h>
#include <stdbool.h>

enum ibpc_type_id {
	IBPC_TYPE_INTEGER,
	IBPC_TYPE_REAL,
	IBPC_TYPE_STRING,
	IBPC_TYPE_BOOLEAN,
	IBPC_TYPE_LIST,
};

typedef long long ibpc_type_integer;
typedef double ibpc_type_real;
struct ibpc_type_string {
	ssize_t cap;
	ssize_t size;
	char *data;
};
typedef bool ibpc_type_boolean;
// struct ibpc_type_list {
// 	struct ibpc_type_list *prev;
// 	struct ibpc_type_list *next;
// 	struct ibpc_value *data;
// }; // FIXME

union ibpc_type {
	ibpc_type_integer integer;
	ibpc_type_real real;
	struct ibpc_type_string string;
	ibpc_type_boolean boolean;
	// ibpc_type_list list;
};

struct ibpc_value {
	enum ibpc_type_id type;
	union ibpc_type value;
};