From 9c895af76231d45c5ca71dcb80a19aedf74c7f05 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 25 Apr 2015 04:41:28 -0500 Subject: [PATCH] Use nice initializer syntax for error strings rather than comments. --- src/assembler/errors.c | 54 ++++++++++++++++++++++---------------------- src/assembler/errors.h | 2 +- src/assembler/preprocessor.c | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/assembler/errors.c b/src/assembler/errors.c index b5ef4f0..d79a1c2 100644 --- a/src/assembler/errors.c +++ b/src/assembler/errors.c @@ -14,36 +14,36 @@ /* Error strings */ static const char *asm_error_types[] = { - "include directive", // ET_INCLUDE - "preprocessor", // ET_PREPROC - "memory layout", // ET_LAYOUT - "symbol table", // ET_SYMBOL - "instruction parser" // ET_PARSER + [ET_INCLUDE] = "include directive", + [ET_PREPROC] = "preprocessor", + [ET_LAYOUT] = "memory layout", + [ET_SYMBOL] = "symbol table", + [ET_PARSER] = "instruction parser" }; static const char *asm_error_descs[] = { - "missing or invalid argument", // ED_INC_BAD_ARG - "infinite recursion detected", // ED_INC_RECURSION - "couldn't read included file", // ED_INC_FILE_READ - - "unknown directive", // ED_PP_UNKNOWN - "multiple values for directive", // ED_PP_DUPLICATE - "missing argument for directive", // ED_PP_NO_ARG - "invalid argument for directive", // ED_PP_BAD_ARG - "directive argument out of range", // ED_PP_ARG_RANGE - - "header offset exceeds given ROM size", // ED_LYT_HEADER_RANGE - "declared ROM size in header exceeds actual size", // ED_LYT_DECLARE_RANGE - "location is out of bounds for the ROM size", // ED_LYT_BOUNDS - "block zero cannot be mapped into a nonzero slot", // ED_LYT_BLOCK0 - "multiple slot declarations for block directive", // ED_LYT_SLOTS - "location overlaps with instruction or data", // ED_LYT_OVERLAP - "location overlaps with ROM header", // ED_LYT_OVERLAP_HEAD - - "duplicate definitions for label", // ED_SYM_DUPE_LABELS - "undefined reference to label", // ED_SYM_NO_LABEL - - "syntax error" // ED_PARSE_SYNTAX + [ED_INC_BAD_ARG] = "missing or invalid argument", + [ED_INC_RECURSION] = "infinite recursion detected", + [ED_INC_FILE_READ] = "couldn't read included file", + + [ED_PP_UNKNOWN] = "unknown directive", + [ED_PP_DUPLICATE] = "multiple values for directive", + [ED_PP_NO_ARG] = "missing argument for directive", + [ED_PP_BAD_ARG] = "invalid argument for directive", + [ED_PP_ARG_RANGE] = "directive argument out of range", + + [ED_LYT_HEADER_RANGE] = "header offset exceeds given ROM size", + [ED_LYT_DECL_RANGE] = "declared ROM size in header exceeds actual size", + [ED_LYT_BOUNDS] = "location is out of bounds for the ROM size", + [ED_LYT_BLOCK0] = "block zero cannot be mapped into a nonzero slot", + [ED_LYT_SLOTS] = "multiple slot declarations for block directive", + [ED_LYT_OVERLAP] = "location overlaps with instruction or data", + [ED_LYT_OVERLAP_HEAD] = "location overlaps with ROM header", + + [ED_SYM_DUPE_LABELS] = "duplicate definitions for label", + [ED_SYM_NO_LABEL] = "undefined reference to label", + + [ED_PARSE_SYNTAX] = "syntax error" }; /* Internal structs */ diff --git a/src/assembler/errors.h b/src/assembler/errors.h index 5f3383d..1e28444 100644 --- a/src/assembler/errors.h +++ b/src/assembler/errors.h @@ -29,7 +29,7 @@ typedef enum { ED_PP_ARG_RANGE, ED_LYT_HEADER_RANGE, - ED_LYT_DECLARE_RANGE, + ED_LYT_DECL_RANGE, ED_LYT_BOUNDS, ED_LYT_BLOCK0, ED_LYT_SLOTS, diff --git a/src/assembler/preprocessor.c b/src/assembler/preprocessor.c index ab0b368..dd67072 100644 --- a/src/assembler/preprocessor.c +++ b/src/assembler/preprocessor.c @@ -500,7 +500,7 @@ ErrorInfo* preprocess(AssemblerState *state, const LineBuffer *source) if (rom_size_line && rom_declsize_line && size_code_to_bytes(state->header.rom_size) > state->rom_size) { - ei = error_info_create(rom_size_line, ET_LAYOUT, ED_LYT_DECLARE_RANGE); + ei = error_info_create(rom_size_line, ET_LAYOUT, ED_LYT_DECL_RANGE); error_info_append(ei, rom_declsize_line); goto cleanup; }