-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.h
49 lines (39 loc) · 1.01 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
#ifndef EFP_AST_H
#define EFP_AST_H
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "tokens.h"
#include "util.h"
struct element {
struct element* parent;
char* key;
int num_fields;
struct field** fields;
int num_elements;
struct element** elements;
};
union value {
int number;
float decimal;
char* string;
char* identifier;
};
struct field_value {
int is_array; // should only be used in prototype tree
enum token_type type;
union value value;
union value def;
int min, max; // for array sizes
};
struct field {
char* key;
int num_values;
struct field_value** values;
};
struct element* create_element(struct element* parent, char* key);
void create_field(struct element* parent, char* key);
void add_field_value(struct field* field, struct field_value* value);
struct field* element_field(struct element* e, const char* key);
struct element* element_element(struct element* e, const char* key);
#endif