-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.h
More file actions
57 lines (48 loc) · 1.39 KB
/
parser.h
File metadata and controls
57 lines (48 loc) · 1.39 KB
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
#ifndef RAON_PARSER_H
#define RAON_PARSER_H
#include "lexer.h"
#include <stdbool.h>
#include <stdint.h>
#define VEC_ITEM_TYPE struct raon_value
#define VEC_SUFFIX raon_value
#include "vendor/vector.h"
#define VEC_ITEM_TYPE struct raon_entry
#define VEC_SUFFIX raon_entry
#include "vendor/vector.h"
enum raon_value_type {
raon_value_type_string,
raon_value_type_int,
raon_value_type_bool,
raon_value_type_block,
raon_value_type_array,
raon_value_type_error,
};
struct raon_value {
enum raon_value_type type;
union {
char *str_val;
intptr_t int_val;
bool bool_val;
struct vector_of_raon_entry *block_val;
struct vector_of_raon_value *array_val;
};
};
enum raon_key_type {
raon_field_type_string,
raon_field_type_int,
raon_field_type_error,
};
struct raon_entry {
enum raon_key_type field_type;
union {
char *str_field;
intptr_t int_field;
};
struct raon_value value;
};
struct raon_entry raon_parse_entry(struct raon_lexer *lexer, struct raon_token first_token);
struct raon_value raon_parse_value(struct raon_lexer *lexer, struct raon_token first_token);
struct vector_of_raon_value *raon_parse_array(struct raon_lexer *lexer, struct raon_token first_token);
struct vector_of_raon_entry *raon_parse_block(struct raon_lexer *lexer, struct raon_token first_token);
struct vector_of_raon_entry *raon_parse(char *str);
#endif