-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_api.c
96 lines (84 loc) · 1.31 KB
/
c_api.c
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <stddef.h>
// This file defines all the data required to compile proc macro shared object
typedef enum {
T_IDENT,
T_INTEGER,
T_STRING,
T_ASSIGN,
T_PLUS,
T_MINUS,
T_BANG,
T_ASTERISK,
T_SLASH,
T_ARROW,
T_PERIOD,
T_TILDE,
T_AMPERSAND,
T_BAR,
T_EQUAL,
T_NOTEQUAL,
T_LESSTHAN,
T_GREATERTHAN,
T_LESSEQUAL,
T_GREATEREQUAL,
T_AND,
T_OR,
T_SHL,
T_SHR,
T_COMMA,
T_SEMICOLON,
T_COLON,
T_LPAREN,
T_RPAREN,
T_LBRACE,
T_RBRACE,
T_LBRACKET,
T_RBRACKET,
T_CONST,
T_TRUE,
T_FALSE,
T_LET,
T_FN,
T_ENUM,
T_STRUCT,
T_IF,
T_WHILE,
T_FOR,
T_ELSE,
T_RETURN,
T_AS,
T_CONTINUE,
T_BREAK,
T_U8,
T_U16,
T_U32,
T_U64,
T_I8,
T_I16,
T_I32,
T_I64,
T_USIZE,
T_ISIZE,
T_BOOL,
T_VOID,
T_NULL,
} TokenTreeTag;
typedef struct {
TokenTreeTag tag;
char *payload;
} Token;
typedef struct {
void *ptr;
size_t len;
} Slice;
typedef Slice (*MacroFn)(Slice);
typedef struct {
const char *name;
MacroFn fn;
} Macro;
Macro _macros[] = {};
// Compiler expects macros symbol to be defined in a shared object
Slice macros = {
.ptr = &_macros,
.len = sizeof(_macros) / sizeof(_macros[0])
};