]> thyrsus.com Git - cupl.git/commitdiff
Simplify the parse tree.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 11 Nov 1994 19:24:43 +0000 (19:24 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 11 Nov 1994 19:24:43 +0000 (19:24 +0000)
interpret.c

index 10fc43a2c37566010bc4dcd869c40d2a73d66ee5..a7a7d5b5e2b59e564d7d66ed31c167086ad309be 100644 (file)
@@ -8,7 +8,11 @@ SYNOPSIS
 
 DESCRIPTION
    This code does interpretation, static checking, and label resolution
-of a CUPL parse tree.  Actual execution is handed off to execute(). 
+of a CUPL parse tree.  Actual execution is handed off to execute().
+
+NOTE
+   The NOTE: comments describe a few things that will need to be done 
+differently if we get a compiler back end.
 
 *****************************************************************************/
 /*LINTLIBRARY*/
@@ -291,6 +295,17 @@ static bool r_label_rewrite(node *tp)
        }
     }
 
+    /*
+     * Remove all label nodes, now that we've resolved them.
+     * NOTE: we must suppress this if we ever do a compiler back end!
+     */
+    if (tp->car && tp->car->type == LABEL)
+    {
+       node *oldnode = tp->car;
+       tp->car = tp->car->cdr;
+       free(oldnode);
+    }
+
     return(TRUE);
 }
 
@@ -308,6 +323,10 @@ static void rewrite(node *tree)
                break;
 
            case BLOCK:
+               /*
+                * NOTE: if we do a compiler back end, we probably want
+                * to suppress the cdr operation.
+                */
                np->car->car->syminf->target = np->cdr;
                break;