-
Notifications
You must be signed in to change notification settings - Fork 4
/
reader.h
38 lines (29 loc) · 1018 Bytes
/
reader.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
#ifndef __MAL_READER__
#define __MAL_READER__
#include <stddef.h>
#include "types.h"
typedef struct Token {
char* str;
struct Token* next;
} Token;
typedef struct Reader {
Token* token;
} Reader;
char* reader_next(Reader* reader);
char* reader_peek(Reader* reader);
static const char PATTERN[] = "[\\s,]*(~@|[\\[\\]{}()'`~^@]|\"\"\"(?:.|\\n)*?\"\"\"|\"(?:\\\\.|[^\\\\\"])*\"?|/(?:\\\\.|[^\\\\/])*/|;.*|[^\\s\\[\\]{}('\"`,;)]*)";
Token* tokenize(char* code);
MalType* read_str(char* code);
MalType* read_form(Reader* reader);
MalType* read_keyword(Reader *reader);
MalType* read_quote(Reader *reader, const char *expanded);
MalType* read_with_meta(Reader *reader);
MalType* read_list(Reader* reader);
MalType* read_vector(Reader* reader);
MalType* read_hashmap(Reader *reader);
MalType* read_string(Reader *reader);
MalType* read_triple_quoted_string(Reader *reader);
MalType* read_regex(Reader *reader);
char unescape_char(char *token, size_t *i, size_t len);
MalType* read_atom(Reader* reader);
#endif