aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2022-02-01 18:36:52 +0100
committerBad Diode <bd@badd10de.dev>2022-02-01 18:36:52 +0100
commitee1a5de91c875fb66724dc21c02333bfebe2a812 (patch)
treed3eaa226816d295bb9dc48a2aed27044832ec413 /src/main.c
parent3156265c7b2da8cc43fee996c0518ea274d39c8a (diff)
downloadbdl-ee1a5de91c875fb66724dc21c02333bfebe2a812.tar.gz
bdl-ee1a5de91c875fb66724dc21c02333bfebe2a812.zip
Add new syntax to lexer and prepare refactor
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/main.c b/src/main.c
index 30eab2b..17dd481 100644
--- a/src/main.c
+++ b/src/main.c
@@ -7,8 +7,8 @@
7#include "string_view.c" 7#include "string_view.c"
8#include "errors.c" 8#include "errors.c"
9#include "lexer.c" 9#include "lexer.c"
10#include "parser.c" 10// #include "parser.c"
11#include "ir.h" 11// #include "ir.h"
12// #include "compiler.h" 12// #include "compiler.h"
13 13
14void 14void
@@ -23,34 +23,32 @@ halt(void) {
23 23
24void 24void
25process_source(const StringView *source, const char *file_name) { 25process_source(const StringView *source, const char *file_name) {
26 Errors errors = {0};
27
28 // Read tokens. 26 // Read tokens.
29 Token *tokens = tokenize(source, &errors); 27 Token *tokens = tokenize(source);
30 if (errors.n != 0) { 28 print_tokens(tokens);
31 report_errors(&errors, file_name); 29 check_errors(file_name);
32 array_free(tokens); 30 // if (errors.n != 0) {
33 exit(EXIT_FAILURE); 31 // exit(EXIT_FAILURE);
34 } 32 // }
35 33
36 // Parser. 34 // // Parser.
37 Program program = parse(tokens, &errors); 35 // Program program = parse(tokens, &errors);
38 if (errors.n != 0) { 36 // if (errors.n != 0) {
39 report_errors(&errors, file_name); 37 // report_errors(&errors, file_name);
40 free_objects(); 38 // free_objects();
41 array_free(tokens); 39 // array_free(tokens);
42 exit(EXIT_FAILURE); 40 // exit(EXIT_FAILURE);
43 } 41 // }
44 array_free(tokens); 42 // array_free(tokens);
45 43
46 // TODO: Optimization. 44 // // TODO: Optimization.
47 45
48 // Compilation. 46 // // Compilation.
49 ProgramIr program_ir = compile(program); 47 // ProgramIr program_ir = compile(program);
50 (void)program_ir; 48 // (void)program_ir;
51 49
52 // Free resources. 50 // // Free resources.
53 free_objects(); 51 // free_objects();
54} 52}
55 53
56void 54void