From e72650a093bd1530c8f36066b91764eafd4dc6d2 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 11 Nov 1994 19:24:43 +0000 Subject: [PATCH] Simplify the parse tree. --- interpret.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/interpret.c b/interpret.c index 10fc43a..a7a7d5b 100644 --- a/interpret.c +++ b/interpret.c @@ -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; -- 2.43.0