]> git.mdlowis.com Git - projs/tide.git/commitdiff
integrate linting compiler script
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 9 Oct 2019 00:46:05 +0000 (20:46 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 9 Oct 2019 00:46:05 +0000 (20:46 -0400)
Rsconscript
alcc

index 246a6f71b2f10a4288e88bd1d33853ee9e3151c9..5896af31ea6af294754c47a12753652c75e13eec 100644 (file)
@@ -19,7 +19,7 @@ build do
 
   # Build library and binaries
   env.Library("libtide.a", glob("src/lib/**/*.c"))
-  (glob("src/*.c") - ["src/term.c"]).each do |src|
+  (glob("src/*.c") - ["src/term.c", "src/tsed.c"]).each do |src|
     bin = File.basename(src).sub(/\.[^\.]$/,'')
     env.Program("bin/#{bin}", [src, "libtide.a"])
   end
diff --git a/alcc b/alcc
index e7d1b3f74e4d17e382e63ef137a3441854224d8d..c226c0b0b1aad1310453dc0fe968497eaa7b88c0 100755 (executable)
--- a/alcc
+++ b/alcc
@@ -176,31 +176,26 @@ script=$(cat <<EOS
     }
 
     function close_function(){
-        if (nreturns > 1)
-        {
-            error("functions should have a maximum of one return statement")
-        }
-
-        if ((FNR - linenum) > MAXLINES)
-        {
-            warn("function is " (FNR - linenum) " lines long. blocks larger than 50 lines are considered too complex")
-        }
+    if (nreturns > 1)
+    {
+        error("functions should have a maximum of one return statement")
+    }
 
-        if (level < 0)
-        {
-            error("too many closing braces detected")
-        }
+    if ((FNR - linenum) > MAXLINES)
+    {
+        warn("function is " (FNR - linenum) " lines long. blocks larger than 50 lines are considered too complex")
+    }
 
-        if (!privatefn && (nasserts == 0))
-        {
-            warn("public function has no assertions")
-        }
+    if (level < 0)
+    {
+        error("too many closing braces detected")
+    }
 
-        privatefn = 0
-        nasserts = 0
-        nreturns = 0
-        infunc = 0
+    if (!privatefn && (nasserts == 0))
+    {
+        warn("public function has no assertions")
     }
+}
 
     # if we're in a comment block, look for the end
     (incomment && match(\$0, /\*\//)) {
@@ -228,19 +223,21 @@ script=$(cat <<EOS
         closing = gsub(/}/, "")
         get_syms(\$0, M);
 
-        # reset state if not in a function
         if (level == 0)
         {
             linenum = FNR + 1
-            privatefn = 0
-            nasserts = 0
-            nreturns = 0
-            infunc = 0
         }
 
-        if (!level && paren && opening)
+        # reset state when we potentially encounter a new function
+        if (level == 0 && paren)
         {
-            warn("function braces should be on their own lines")
+            privatefn = 0
+            nasserts = 0
+            nreturns = 0
+            if (opening)
+            {
+                warn("function braces should be on their own lines")
+            }
         }
 
         process_idents(opening, closing)