From: Eric S. Raymond Date: Fri, 11 Nov 1994 19:24:43 +0000 (+0000) Subject: Simplify the parse tree. X-Git-Tag: 1-2~40 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=e72650a093bd1530c8f36066b91764eafd4dc6d2;p=cupl.git Simplify the parse tree. --- 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;