blob: 0a782eb710b0df57828ebb579c8340ee13f56f5b (
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
|
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "vec.h"
enum token_type {
Token_Comment,
Token_Key,
Token_StringValue,
Token_BoolValue,
Token_IntValue,
Token_Table,
Token_InlineTable,
Token_Error,
};
struct token {
enum token_type type;
void *data;
uint32_t len;
uint32_t row;
uint32_t col;
};
typedef size_t (*getbytes)(size_t nbytes, uint8_t *buf, void *userdata);
struct reader {
getbytes getbytes;
void *userdata;
};
struct parser {
uint32_t row;
uint32_t col;
struct reader reader;
VEC(uint8_t) buffer;
};
struct parser parser_create(struct reader reader);
void parser_destroy(struct parser *parser);
bool parser_next_token(struct parser *state, struct token *token_out);
|