32 lines
1.1 KiB
C
32 lines
1.1 KiB
C
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
|
|
typedef struct {
|
|
size_t idx;
|
|
int line;
|
|
int col;
|
|
} Loc;
|
|
|
|
#define REPORTF_ERROR(FMT, ...) \
|
|
(fprintf( \
|
|
stderr, "\x1b[1;91merror\x1b[1;97m: " FMT "\x1b[0m\n", __VA_ARGS__))
|
|
#define REPORTF_INFO(FMT, ...) \
|
|
(fprintf(stderr, "\x1b[1;96minfo\x1b[1;97m: " FMT "\x1b[0m\n", __VA_ARGS__))
|
|
#define REPORTF_WARNING(FMT, ...) \
|
|
(fprintf( \
|
|
stderr, "\x1b[1;93mwarning\x1b[1;97m: " FMT "\x1b[0m\n", __VA_ARGS__))
|
|
|
|
void print_report_loc(
|
|
const char* filename, const char* text, size_t text_len, Loc loc);
|
|
|
|
typedef struct {
|
|
const char* filename;
|
|
const char* text;
|
|
size_t text_len;
|
|
} Reporter;
|
|
|
|
void reporter_print_loc(Reporter* rep, Loc loc);
|
|
void reporter_error_with_loc(Reporter* rep, const char* msg, Loc loc);
|