-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast.h
74 lines (64 loc) · 1.27 KB
/
ast.h
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
#pragma once
#include <stdbool.h>
#include "allocator.h"
#include "hash_trie.h"
typedef struct ASTNode ASTNode;
typedef ASTNode* ASTNodePtr;
typedef union
{
char *string;
int64_t integer;
float number;
float vector[4];
bool boolean;
struct
{
ASTNode *file; // ASTFileReference
ASTNode *function; // ASTIdentifier
} function;
} ASTLiteralValue;
// typedef struct
// {
// ASTNode *node;
// } ASTExpr;
// typedef struct
// {
// ASTNode *node;
// } ASTStmt;
#include "ast.type.h"
#define AST_ENUM(UPPER, TYPE, LOWER) UPPER,
enum
{
AST_INVALID,
AST_X_MACRO(AST_ENUM) AST_MAX
};
#define AST_STRINGS(UPPER, TYPE, LOWER) #TYPE,
static const char *ast_node_names[] = { "invalid", AST_X_MACRO(AST_STRINGS) NULL };
#define AST_FIELD_DATA(UPPER, TYPE, LOWER) TYPE LOWER##_data;
struct ASTNode
{
union
{
AST_X_MACRO(AST_FIELD_DATA)
};
uint32_t type;
size_t offset;
int line;
struct ASTNode *next;
};
// typedef struct ASTFile ASTFile;
// struct ASTFile
// {
// HashTrie functions; // ASTFunction
// char path[256];
// // char *source;
// // Node *includes; // TODO: FIXME reverse order
// };
// typedef struct ASTProgram ASTProgram;
// struct ASTProgram
// {
// Allocator *allocator;
// HashTrie files; // ASTFile
// char base_path[256];
// // const char *source;
// };