aboutsummaryrefslogtreecommitdiffstats
path: root/src/bootstrap/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bootstrap/main.c')
-rwxr-xr-xsrc/bootstrap/main.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/bootstrap/main.c b/src/bootstrap/main.c
index 662831e..113ee48 100755
--- a/src/bootstrap/main.c
+++ b/src/bootstrap/main.c
@@ -5,10 +5,19 @@
5 5
6#include "string_view.c" 6#include "string_view.c"
7#include "read_line.c" 7#include "read_line.c"
8#include "lexer.c"
8 9
9void 10void
10process_source(const StringView *source) { 11process_source(const StringView *source) {
11 sv_write(source, stdout); 12 Tokens tokens = tokenize(source);
13
14 // Print tokens.
15 for (size_t i = 0; i < tokens.size; i++) {
16 Token tok = tokens.buf[i];
17 print_token(tok);
18 }
19
20 free(tokens.buf);
12} 21}
13 22
14#define REPL_PROMPT "bdl> " 23#define REPL_PROMPT "bdl> "
@@ -57,13 +66,13 @@ run_file(char *file_name) {
57 fclose(file); 66 fclose(file);
58} 67}
59 68
60#define STDIN_BUF_SIZE 16 69#define STDIN_BUF_CAP 16
61 70
62void 71void
63run_stdin(void) { 72run_stdin(void) {
64 size_t buf_size = 0; 73 size_t buf_size = 0;
65 size_t buf_cap = STDIN_BUF_SIZE; 74 size_t buf_cap = STDIN_BUF_CAP;
66 char *source = malloc(sizeof(char) * buf_cap); 75 char *source = malloc(buf_cap * sizeof(char));
67 76
68 char c; 77 char c;
69 while ((c = getchar()) != EOF) { 78 while ((c = getchar()) != EOF) {