diff options
| author | gingerBill <ginger.bill.22@gmail.com> | 2016-07-09 00:31:57 +0100 |
|---|---|---|
| committer | gingerBill <ginger.bill.22@gmail.com> | 2016-07-09 00:31:57 +0100 |
| commit | f7a669d342c96451a3e0be84e2e51af8631f90ec (patch) | |
| tree | c0c81ed66c8229c182bac13ef8107ca642debd74 /src/generator.cpp | |
| parent | 9ba2a6d02cab3feff9d70f7bb9c2e8eb72bc5533 (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.cpp | 36 |
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; - } } |