-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmolmath.h
More file actions
50 lines (39 loc) · 826 Bytes
/
smolmath.h
File metadata and controls
50 lines (39 loc) · 826 Bytes
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
// Copyright (c) 2024 Fabian Stiewitz <fabian (at) stiewitz.pw>
// Licensed under the EUPL-1.2
#ifndef SMOLMATH_SMOLMATH_H
#define SMOLMATH_SMOLMATH_H
#ifdef __cplusplus
extern "C" {
#endif
struct exp_t;
struct op_t {
char op;
int precedence;
struct exp_t *left;
struct exp_t *right;
};
#define ISNUM(T) ((T) == L || (T) == F)
struct val_t {
enum {
L, F, N, S
} type;
char suffix;
union {
long l;
double f;
char *ns;
};
};
struct exp_t {
enum {
V, OP
} type;
char data[];
};
typedef void (*smolmath_cb)(struct exp_t *exp);
void smolmath_log(struct exp_t *exp);
int smolmath_parse(char *line, const char *precedence, char minus, const char *alnum, smolmath_cb cb);
#ifdef __cplusplus
};
#endif
#endif //SMOLMATH_SMOLMATH_H