aboutsummaryrefslogtreecommitdiff
path: root/src/generator.cpp
diff options
context:
space:
mode:
authorgingerBill <ginger.bill.22@gmail.com>2016-07-09 00:31:57 +0100
committergingerBill <ginger.bill.22@gmail.com>2016-07-09 00:31:57 +0100
commitf7a669d342c96451a3e0be84e2e51af8631f90ec (patch)
treec0c81ed66c8229c182bac13ef8107ca642debd74 /src/generator.cpp
parent9ba2a6d02cab3feff9d70f7bb9c2e8eb72bc5533 (diff)
Initial release version
* Code cleanup * Fix some TODOs * Reduce heap allocation use and replace with arena allocation
Diffstat (limited to 'src/generator.cpp')
-rw-r--r--src/generator.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/generator.cpp b/src/generator.cpp
index bd081f184..d85453a75 100644
--- a/src/generator.cpp
+++ b/src/generator.cpp
@@ -13,31 +13,25 @@ struct Generator {
#define print_generator_error(p, token, fmt, ...) print_generator_error_(p, __FUNCTION__, token, fmt, ##__VA_ARGS__)
void print_generator_error_(Generator *g, char *function, Token token, char *fmt, ...) {
- va_list va;
// NOTE(bill): Duplicate error, skip it
- if (g->error_prev_line == token.line && g->error_prev_column == token.column) {
- goto error;
+ if (g->error_prev_line != token.line || g->error_prev_column != token.column) {
+ va_list va;
+
+ g->error_prev_line = token.line;
+ g->error_prev_column = token.column;
+
+ #if 0
+ gb_printf_err("%s()\n", function);
+ #endif
+ va_start(va, fmt);
+ gb_printf_err("%s(%td:%td) %s\n",
+ g->checker->parser->tokenizer.fullpath, token.line, token.column,
+ gb_bprintf_va(fmt, va));
+ va_end(va);
+
}
- g->error_prev_line = token.line;
- g->error_prev_column = token.column;
-
-#if 0
- gb_printf_err("%s()\n", function);
-#endif
- va_start(va, fmt);
- gb_printf_err("%s(%td:%td) %s\n",
- g->checker->parser->tokenizer.fullpath, token.line, token.column,
- gb_bprintf_va(fmt, va));
- va_end(va);
-
-error:
g->error_count++;
- // NOTE(bill): If there are too many errors, just quit
- if (g->error_count > MAX_GENERATOR_ERROR_COUNT) {
- gb_exit(1);
- return;
- }
}