blob: bbb238c6c4ae17c6aaf941f64a229498827ea468 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#include "interpret.h"
#include "tokenizer.h"
#include <stdbool.h>
SandInterpretResult sand_interpret(SandState *S, const char *filename, const char *source, size_t source_length) {
SandTokenizer tokenizer = sand_create_tokenizer(source, source_length, filename);
while (true) {
SandToken token = sand_get_next_token(&tokenizer);
sand_print_location(stdout, &token.location);
printf(": %s \"%.*s\"\n", sand_token_kind_to_string(token.kind), (int)token.content_length, token.content);
if (token.kind == SAND_TOKEN_EOF) {
break;
}
}
return SAND_INTERPRET_OK;
}
|