break;
case DIAGNOSTIC_UNEXPECTED_IDENT:
+ /*
+ * TODO: better way to determine the identifier. So far we
+ * "assume" it's the first one in the token stream, the issue
+ * with this, is it'ss possible that it isn't the first ident
+ * in the stream. In all likely hood, the parser itself should
+ * carry a "current token in line" count so we can simply use
+ * it as a index into vec_last(read)->tokens. This will also
+ * allow for other diagnostics involving unexpected tokens.
+ */
for (itr = 0; len < vec_size(vec_last(read)->tokens); len++) {
if (vec_last(read)->tokens[len] == TOKEN_IDENT)
break;
OPTS_OPTION_U32(OPTION_STANDARD) = COMPILER_GMQCC;
+ OPTS_OPTION_BOOL(OPTION_DIAGNOSTICS) = true;
} else if (!strcmp(argarg, "qcc")) {
GMQCC_DEFINE_FLAG(MAX_ARRAY_SIZE)
GMQCC_DEFINE_FLAG(ADD_INFO)
GMQCC_DEFINE_FLAG(CORRECTION)
+ GMQCC_DEFINE_FLAG(DIAGNOSTICS)
#endif
/* some cleanup so we don't have to */
vcompile_error(parser->lex->tok.ctx, fmt, ap);
va_end(ap);
- diagnostic_calculate(parser->lex->name, parser->lex->line, parser->lex->column, parser->diagnostic);
+ if (OPTS_OPTION_BOOL(OPTION_DIAGNOSTICS))
+ diagnostic_calculate(parser->lex->name, parser->lex->line, parser->lex->column, parser->diagnostic);
}
/* returns true if it counts as an error */
r = vcompile_warning(parser->lex->tok.ctx, warntype, fmt, ap);
va_end(ap);
- diagnostic_calculate(parser->lex->name, parser->lex->line, parser->lex->column, parser->diagnostic);
+ if (OPTS_OPTION_BOOL(OPTION_DIAGNOSTICS))
+ diagnostic_calculate(parser->lex->name, parser->lex->line, parser->lex->column, parser->diagnostic);
return r;
}