diff options
| author | hachem <im@hachem.wtf> | 2026-08-31 02:01:44 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-08-31 02:01:44 +0200 |
| commit | ce9f0d32c33333161cf9a5c2b7446d80fa0f13b5 (patch) | |
| tree | 3ceb2594de443f7928c5300d42c00428778eae11 /src/main.c | |
| parent | cf24f576891ece60bdf04928d3c39dd0bbb9b5f6 (diff) | |
feat: add diagnostics module with source-anchored caret errors
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -2,6 +2,7 @@ #include "io/file.h" #include "cli/args.h" +#include "diag/diag.h" #include "sema/sema.h" #include "lexer/lexer.h" #include "codegen/nasm.h" @@ -19,7 +20,7 @@ int main(int argc, char** argv) if (args.target != ASSEMBLER_NASM) { - fprintf(stderr, "error: only the nasm target is supported\n"); + report_error_message("only the nasm target is supported"); return 1; } @@ -28,6 +29,7 @@ int main(int argc, char** argv) return 1; struct Lexer lexer = create_lexer(source.data); + lexer.name = args.input_path; struct Program program; if (!parse_program(&lexer, &program)) @@ -37,7 +39,8 @@ int main(int argc, char** argv) return 1; } - if (!analyze_program(&program)) + struct Source diagnostics = { args.input_path, source.data }; + if (!analyze_program(diagnostics, &program)) { free_program(&program); free_file(&source); @@ -50,7 +53,9 @@ int main(int argc, char** argv) out = fopen(args.output_path, "w"); if (out == NULL) { - fprintf(stderr, "error: could not open '%s' for writing\n", args.output_path); + char message[256]; + snprintf(message, sizeof(message), "could not open '%s' for writing", args.output_path); + report_error_message(message); free_program(&program); free_file(&source); return 1; |
