diff options
author | Bad Diode <bd@badd10de.dev> | 2022-02-01 18:36:52 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2022-02-01 18:36:52 +0100 |
commit | ee1a5de91c875fb66724dc21c02333bfebe2a812 (patch) | |
tree | d3eaa226816d295bb9dc48a2aed27044832ec413 /src/main.c | |
parent | 3156265c7b2da8cc43fee996c0518ea274d39c8a (diff) | |
download | bdl-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.c | 56 |
1 files changed, 27 insertions, 29 deletions
@@ -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 | ||
14 | void | 14 | void |
@@ -23,34 +23,32 @@ halt(void) { | |||
23 | 23 | ||
24 | void | 24 | void |
25 | process_source(const StringView *source, const char *file_name) { | 25 | process_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 | ||
56 | void | 54 | void |