From: Dale Weiler Date: Fri, 31 May 2013 06:48:40 +0000 (+0000) Subject: Added another diagnostic and test, also fixed alginment in testsuite. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1a6b8055026c30a3ad0e6a21964e3eb82d52296c;p=xonotic%2Fgmqcc.git Added another diagnostic and test, also fixed alginment in testsuite. --- diff --git a/diag.c b/diag.c index 83b8f99..81c831e 100644 --- a/diag.c +++ b/diag.c @@ -151,6 +151,15 @@ static void diagnostic_feed(const char *file, size_t line, size_t column, size_t } switch (diagnostic) { + case DIAGNOSTIC_EXPECTED_END: + for (; len < vec_size(vec_last(read)->values); len++) + space += strlen(vec_last(read)->values[len]); + + /* +/- 1 because of the ^ */ + len = space - column - 1; + space = column + 1; + break; + case DIAGNOSTIC_EXPRESSION_CASE: case DIAGNOSTIC_SEMICOLON: for (; len < vec_size(vec_last(read)->values); len++) @@ -243,20 +252,14 @@ void diagnostic_calculate(const char *file, size_t line, size_t column, size_t d * enable the marker (to show where it's missing). */ case DIAGNOSTIC_SEMICOLON: - linebeg++; - marker = true; - break; - case DIAGNOSTIC_EXPRESSION_CASE: + case DIAGNOSTIC_EXPECTED_END: linebeg++; marker = true; break; - - case DIAGNOSTIC_EXPECTED: - marker = true; - break; - + case DIAGNOSTIC_UNEXPECTED_IDENT: + case DIAGNOSTIC_EXPECTED: marker = true; break; diff --git a/gmqcc.h b/gmqcc.h index 1882a30..622f303 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -1035,7 +1035,8 @@ enum { DIAGNOSTIC_SEMICOLON, DIAGNOSTIC_EXPRESSION_CASE, DIAGNOSTIC_UNEXPECTED_IDENT, - DIAGNOSTIC_EXPECTED + DIAGNOSTIC_EXPECTED, + DIAGNOSTIC_EXPECTED_END }; void diagnostic_destroy(); diff --git a/parser.c b/parser.c index 5deef69..a4abb0e 100644 --- a/parser.c +++ b/parser.c @@ -2220,6 +2220,7 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma } } if (!concatenated) { + parser->diagnostic = DIAGNOSTIC_EXPECTED_END; parseerror(parser, "expected operator or end of statement"); goto onerr; } diff --git a/test.c b/test.c index 1b0bcbb..6899ff7 100644 --- a/test.c +++ b/test.c @@ -1245,7 +1245,7 @@ static void task_schedualize(size_t *pad) { */ if (vec_size(match) > vec_size(task_tasks[i].tmpl->comparematch)) { for (d = 0; d < vec_size(match) - vec_size(task_tasks[i].tmpl->comparematch); d++) { - con_out(" Expected: Nothing | Got: \"%s\"\n", + con_out(" Expected: Nothing | Got: \"%s\"\n", match[d + vec_size(task_tasks[i].tmpl->comparematch)] ); } diff --git a/tests/diag/expend.qc b/tests/diag/expend.qc new file mode 100644 index 0000000..dc96421 --- /dev/null +++ b/tests/diag/expend.qc @@ -0,0 +1 @@ +const vector foo = '1 2 3' diff --git a/tests/diag/expend.tmpl b/tests/diag/expend.tmpl new file mode 100644 index 0000000..af926b6 --- /dev/null +++ b/tests/diag/expend.tmpl @@ -0,0 +1,9 @@ +I: expend.qc +D: expected end of statement +T: -diagnostic +C: -std=gmqcc +M: expected operator or end of statement +M: 2: const vector foo = '1 2 3' +M: ~~~~~~~^ +M: unexpected eof +