blob: b3e9d7591011917673b60dfd09a446bfc9e67c01 (
plain)
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
|
#ifndef _ast_h
#define _ast_h
#include <stdlib.h>
#include <stddef.h>
typedef enum {
AST_LIST,
AST_NUM,
AST_SYMBOL,
} AstTy;
#define AST_TY_LAST AST_SYMBOL+1
struct _astnode;
typedef struct _astnode AstNode;
typedef struct {
size_t len;
size_t cap;
AstNode *vals;
} AstVec;
struct _astnode {
AstTy ty;
union {
int num;
AstVec list;
char *str;
} as;
};
AstVec astvec_new();
void astvec_append(AstVec *v, AstNode val);
void astnode_append(AstNode *l, AstNode val);
AstNode astnode_new_num(int n);
AstNode astnode_new_list();
AstNode astnode_new_symbol(char *s);
void astnode_disp(AstNode *a);
const char *ast_ty_to_str(AstTy ty);
#endif
|