/* Copyright (C) 1995 by Thomas Glen Smith. All Rights Reserved. */ /* execspet APL2 V1.0.0 ************************************************ * Called by execsper. * ***********************************************************************/ #define INCLUDES APLCHDEF+APLDERIV+APLTOKEN+APLCB+TREE #include "includes.h" int execspet(hit,op,nametok,tok,axistok,cb,cbn) int hit; Apltoken op,nametok,tok,axistok; Aplcb cb,cbn; { Execfree;Execspef;Execspeg;Execspek;Execspel;Execspez;Execterm;Lifo; extern Treelist treehdr; extern int aplerr; Apltoken wrk; int exec_sw=1,iw,nwa=0; Aplcb out=NULL; for (;;) { /* lets me use break */ if (NULL != (wrk = treehdr->avltokhd) && wrk->token_code != LEFT_PAREN) hit = execspel(&tok,&axistok); /* Execspel does some tests to see if it is selective */ /* specification, and returns these values: */ /* 0 == Not selective specification. */ /* -1 == ? */ /* funky_code: It is selective specification. */ if (hit == -1) break; switch(hit) { case 0: /* Execspeg completes the assignment, which is */ /* not selective specification. */ out = execspeg(tok, axistok, op, &iw); break; case SLOPE: case SLOPE_BAR: /* e.g. (1 0 1 0 1)\m)#I5 gives 1 3 5. */ hit = execspek(hit,tok,axistok,op); break; default: /* It is selective specification. */ out = execspez(tok,axistok,op,cb,cbn,&nwa); tok = axistok = NULL; /* Don't free twice. */ if (aplerr) break; exec_sw = 0; /* Indicate execterm invoked. */ execterm(); op = execspef(op,cb,cbn,out,nwa); /* Finish sel. asgn. */ out = NULL; /* freed by execspef */ if (op != NULL) { hit = 1; /* Indicate specification handled. */ op = lifo(&(treehdr->avlexec->avloprst),op); op = NULL; /* don't free twice */ } break; } /* end switch */ tok = axistok = op = NULL; /* don't free twice */ break; } if (exec_sw) execterm(); /* Call if appropriate. */ execfree(tok); execfree(axistok); execfree(op); return(hit); /* indicate selective specification handled */ }