]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Add option to turn on and off the diagnostic system, and added a TODO.
authorDale Weiler <killfieldengine@gmail.com>
Fri, 31 May 2013 06:24:50 +0000 (06:24 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Fri, 31 May 2013 06:24:50 +0000 (06:24 +0000)
diag.c
main.c
opts.def
parser.c

diff --git a/diag.c b/diag.c
index 73807f2b2776dc0357b95a7eb3cfca0ca67df643..83b8f993104f8922f25e1b31938d8f2826740ad5 100644 (file)
--- a/diag.c
+++ b/diag.c
@@ -170,6 +170,15 @@ static void diagnostic_feed(const char *file, size_t line, size_t column, size_t
             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;
diff --git a/main.c b/main.c
index 10db6d3fa1e5f46d2d396ad4916fcf51288b9424..e23f3b5aa6cae77c52113fc1c79b8b9113cdbeb4 100644 (file)
--- a/main.c
+++ b/main.c
@@ -173,6 +173,7 @@ static bool options_parse(int argc, char **argv) {
 
 
                     OPTS_OPTION_U32(OPTION_STANDARD) = COMPILER_GMQCC;
+                    OPTS_OPTION_BOOL(OPTION_DIAGNOSTICS) = true;
 
                 } else if (!strcmp(argarg, "qcc")) {
 
index 520f9b95cb6f0d33872cd756f865d3a805e15168..586384017346f1a83f5d0dc1302c632d0db65075 100644 (file)
--- a/opts.def
+++ b/opts.def
     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 */
index 2d6cd1d1be121f5ad930e57c18d97f664e96f7d2..5deef696157bf851c8f3f59049a06f5ffa5f28dc 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -139,7 +139,8 @@ static void parseerror(parser_t *parser, const char *fmt, ...)
     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 */
@@ -151,7 +152,8 @@ static bool GMQCC_WARN parsewarning(parser_t *parser, int warntype, const char *
     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;
 }