]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Implemented diagnostic for unexpected identifiers
authorDale Weiler <killfieldengine@gmail.com>
Fri, 31 May 2013 04:18:00 +0000 (04:18 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Fri, 31 May 2013 04:18:00 +0000 (04:18 +0000)
diag.c
gmqcc.h
parser.c
test.c

diff --git a/diag.c b/diag.c
index 83c2b93a52a337fe2b47d965f04835b55b134008..c888991253cb77cc84e3904c5aad9525dd9a38b5 100644 (file)
--- a/diag.c
+++ b/diag.c
@@ -160,6 +160,15 @@ static void diagnostic_feed(const char *file, size_t line, size_t beg, size_t en
             space -= beg - end;
             break;
             
+        case DIAGNOSTIC_UNEXPECTED_IDENT:
+            for (itr = 0; len < vec_size(vec_last(read)->tokens); len++) {
+                if (vec_last(read)->tokens[len] == TOKEN_IDENT)
+                    break;
+                space += strlen(vec_last(read)->values[len]);
+            }
+            len = 0;
+            break;
+            
         default:
             break;
     }
@@ -225,6 +234,10 @@ void diagnostic_calculate(const char *file, size_t line, size_t diagnostic) {
             marker = true;
             break;
 
+        case DIAGNOSTIC_UNEXPECTED_IDENT:
+            marker = true;
+            break;
+
         /* Catches the DIAGNOSTIC_NULL and out of range case */
         default:
             return;
diff --git a/gmqcc.h b/gmqcc.h
index 9a41ae5b5aa81481c93e98e5412e4660eecfe0d5..84ddc2a96907bb090bf00cfc8723ff2054c0cba7 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -1030,7 +1030,8 @@ void            ftepp_add_macro        (struct ftepp_s *ftepp, const char *name,
 enum {
     DIAGNOSTIC_NULL,
     DIAGNOSTIC_SEMICOLON,
-    DIAGNOSTIC_EXPRESSION_CASE
+    DIAGNOSTIC_EXPRESSION_CASE,
+    DIAGNOSTIC_UNEXPECTED_IDENT
 };
 
 void diagnostic_destroy();
index 33978562d2d004177460c8b66a9b0acbb368dee1..063c6d2e7a9d09a47e6ccd04c56336f7bfdc9ca5 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1960,11 +1960,13 @@ static bool parse_sya_operand(parser_t *parser, shunt *sy, bool with_labels)
                     correct_free(&corr);
 
                     if (correct) {
+                        parser->diagnostic = DIAGNOSTIC_UNEXPECTED_IDENT;
                         parseerror(parser, "unexpected ident: %s (did you mean %s?)", parser_tokval(parser), correct);
                         mem_d(correct);
                         return false;
                     }
                 }
+                parser->diagnostic = DIAGNOSTIC_UNEXPECTED_IDENT;
                 parseerror(parser, "unexpected ident: %s", parser_tokval(parser));
                 return false;
             }
diff --git a/test.c b/test.c
index 6682983a30e997278cd1745b585480a128bc916d..e693e3e54f2a4ce4ab06fba4ff51597a57f07085 100644 (file)
--- a/test.c
+++ b/test.c
@@ -678,7 +678,6 @@ static bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
             abort();
         }
 
-        /* skip directories */
         if (S_ISDIR(directory.st_mode))
             continue;