From e4e292fce970257a7ee09f547cb905794af1a8d4 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Mon, 6 Aug 2018 01:30:09 +1200 Subject: lex: add filename to error Brings lexing error message format more into line with parser --- lex.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lex.c') diff --git a/lex.c b/lex.c index 6dc38d2..6777e42 100644 --- a/lex.c +++ b/lex.c @@ -6,7 +6,7 @@ #include "common.h" #include "token.h" -#define emit_error(...) fprintf(stderr, "Error (%zd,%zd): ", line_number, 1 + column_number);\ +#define emit_error(...) fprintf(stderr, "%s at (%zd,%zd): ", filename, line_number, 1 + column_number);\ fprintf(stderr, __VA_ARGS__) #define BUFFER_SIZE 1024 @@ -50,6 +50,7 @@ static struct keyword token_descriptors[] = { static char buf[BUFFER_SIZE]; static FILE* fd; +static const char *filename = NULL; static size_t line_number = 0; static size_t column_number = 0; static ssize_t leading_whitespace_len = 0; @@ -230,7 +231,8 @@ lex_line(void) { } struct token * -lex_file(FILE *fd_local) { +lex_file(const char *filename_local, FILE *fd_local) { + filename = filename_local; fd = fd_local; line_number = 1; -- cgit v1.1