]> thyrsus.com Git - cupl.git/commitdiff
One of the sanity checks foound a syntax error!
authorEric S. Raymond <esr@thyrsus.com>
Thu, 3 Nov 1994 00:54:53 +0000 (00:54 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 3 Nov 1994 00:54:53 +0000 (00:54 +0000)
interpret.c
test/fancyquad.cupl
test/quadratic.cupl

index 7185f9cf03cf984f6e563b86449d85c84574f83a..1ffb8d9a7fcb84ac5db8258f10dab4331bbe28c3 100644 (file)
@@ -118,7 +118,7 @@ static bool check_errors(node *tree)
     /* simple sanity check */
     for (n = tree; n; n = n->u.n.right)
        if (n->type != STATEMENT)
-           die("internal error: non-STATEMENT at top level");
+           die("cupl: internal error: non-STATEMENT at top level");
 
     /* make backpointers */
     for_symbols(lp)
@@ -127,12 +127,17 @@ static bool check_errors(node *tree)
     /* mark labels */
     recursive_apply(tree, r_mark_labels);
 
+    /* check for label consistency */
+    for_symbols(lp)
+       if (lp->labelref && !lp->labeldef)
+           die("cupl: label %s referenced but not defined\n", lp->node->u.string);
+
     /* report on the number of labels */
     if (verbose >= DEBUG_CHECKDUMP)
     {
        int             nlabels = 0;
 
-       for (lp = idlist; lp; lp = lp->next)
+       for_symbols(lp)
            if (lp->labeldef)
                nlabels++;
 
@@ -140,11 +145,12 @@ static bool check_errors(node *tree)
            (void) printf("No labels.\n");
        else
        {
-           (void) printf("Labels:");
-           for (lp = idlist; lp; lp = lp->next)
+           (void) printf("Labels:\n");
+           for_symbols(lp)
                if (lp->labeldef)
-                   (void) printf(" %s", lp->node->u.string);
-           (void) printf("\n");
+                   (void) printf("    %s (%d references)\n",
+                                 lp->node->u.string,
+                                 lp->labelref);
        }
     }
 }
index 4964fee100f0a00df0ca28c57228c35bfac85b01..5395af0e1ac0ff45a0433a4a3d10a8e75ad79cd4 100644 (file)
@@ -17,7 +17,7 @@ OTHER LET E = SQRT(-D)
        LET XREAL = -B/(2*A)
        LET XIMAG = E/(2*A)
        WRITE XREAL,XIMAG
-       STOP
+LAST   STOP
 QUADSOL        END
 
 *DATA  N=4
index cfd87a7c8b3a1b5959573e00696ef88caf81e4df..d1683dbdf1ecbf334542fb1f61e7ddd86c8b2e16 100644 (file)
@@ -11,6 +11,6 @@ OTHER LET E = SQRT(-D)
        LET XREAL = -B/(2*A)
        LET XIMAG = E/(2*A)
        WRITE XREAL,XIMAG
-       STOP
+LAST   STOP
 
 *DATA  A=1,B=4,C=8