]> thyrsus.com Git - cupl.git/commitdiff
This version does both performs and gotos.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 11 Nov 1994 20:03:05 +0000 (20:03 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 11 Nov 1994 20:03:05 +0000 (20:03 +0000)
execute.c

index 0afb607c4c225aa1492a36ed44cc63d1f2a60bd9..196e24e47fb619dba7ebed3d2e611db6243a364a 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -40,7 +40,7 @@ static node *popstack(void)
 {
     if (sp <= stack)
        die("too many END statements\n");
-    return(*sp--);
+    return(*--sp);
 }
 
 static void pushstack(node *st)
@@ -157,7 +157,7 @@ static value cupl_eval(node *tree)
 /* recursively evaluate a CUPL parse tree */
 {
     node *pc;  /* pointer to statement being evaluated */
-    static node *next; /* the statement node to evaluate next */
+    node *next;        /* the statement node to evaluate next */
     static jmp_buf nextbuf;    /* end-of-statement handling */
 
     value      leftside, rightside, result, cond;
@@ -569,6 +569,8 @@ static value cupl_eval(node *tree)
                next = pc->cdr;
                if (setjmp(nextbuf) == 0)
                    (void) cupl_eval(pc->car);
+               else
+                   next = popstack();
                break;
            }
        }
@@ -576,7 +578,7 @@ static value cupl_eval(node *tree)
        return(result);
 
     case GO:
-       next = tree->car;
+       pushstack(tree->car);
        longjmp(nextbuf, 1);
   
     case IF: