From 358157fea410f275ae147a727d8cbffa7c2569b8 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 3 Nov 1994 00:54:53 +0000 Subject: [PATCH] One of the sanity checks foound a syntax error! --- interpret.c | 18 ++++++++++++------ test/fancyquad.cupl | 2 +- test/quadratic.cupl | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/interpret.c b/interpret.c index 7185f9c..1ffb8d9 100644 --- a/interpret.c +++ b/interpret.c @@ -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); } } } diff --git a/test/fancyquad.cupl b/test/fancyquad.cupl index 4964fee..5395af0 100644 --- a/test/fancyquad.cupl +++ b/test/fancyquad.cupl @@ -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 diff --git a/test/quadratic.cupl b/test/quadratic.cupl index cfd87a7..d1683db 100644 --- a/test/quadratic.cupl +++ b/test/quadratic.cupl @@ -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 -- 2.43.0