/*********************************************************/ /* */ /* PISTOL-Portably Implemented Stack Oriented Language */ /* Version 1.3 */ /* (C) 1982 by Ernest E. Bergmann */ /* Physics, Building #16 */ /* Lehigh Univerisity */ /* Bethlehem, Pa. 18015 */ /* */ /* Permission is hereby granted for all reproduction and */ /* distribution of this material provided this notice is */ /* is included. */ /* */ /*********************************************************/ /* fourth module, February, 1982 */ #include "bdscio.h" #include "pistol.h" interpret(i) unsigned i; { instr=i; do {ip += W; if(instr<(RESTOR+1)) /*pint(instr);*/ (*farray[instr])(); else { rpush(ip); ip=instr;} Pw = ip; instr=*Pw; /* trace patch here */ if(rptr==(ram[-19].in-2)) {savinstr=instr; savlevel=rptr; instr=ram[-26].in; ip -= W; do {ip += W; if(instr<(RESTOR+1)) /*pint(instr);*/ (*farray[instr])(); else{rpush(ip); ip=instr;} Pw=ip; instr=*Pw; } while( rptr > savlevel); instr=savinstr; } } while (rptr >= 0); ip -= W; } fname(name) /*name[0]=length,name[length+1]=0*/ char name[NAMESIZE]; { drop(); Pc=stack[1+stkptr]; movmem(1+Pc,1+name,*Pc); name[1+*Pc]='\0'; name[0]=*Pc; } rewrit(name,iobuf) char name[NAMESIZE],*iobuf; { if(stkptr<1)merr(undflo); if(name[0]) {if(ram[-24].in) carret(); message(redef);message(name);carret(); closout(iobuf); } fname(name); if(0>fcreat(1+name,iobuf)) { if(ram[-24].in) carret(); message(name); merr(nopen); } } beginop() { pushck('B'); push(ram[-2].in); } endop() { if(strings[1+strings[1]]=='B') {dropck(); compile(PIF); compile(stack[stkptr]-ram[-2].in); drop(); } else synterr(); } repet() { Pc=&strings[1]+strings[1];Pc2=Pc-1; dropck();dropck(); if((*Pc=='F') && (*Pc2=='B')) {compile(PELSE); compile(stack[stkptr-1]-ram[-2].in); touchup(); drop(); } else synterr(); } pdollar() { enter(); Pw=ip; move(ip+W,ram[-3].pw,*Pw-W); Pw=ip;ram[-3].in += *Pw-W; fenter(ram[-3].in-W); Pw=ram[-6].pw;Pw=*Pw;Pw--; *Pw=COMPME; permstrings(); Pw=ip;ip += *Pw; } pcolon() { enter(); Pw=ip; move(ip+W,ram[-3].pw,*Pw-W); Pw=ip;ram[-3].in += *Pw-W; fenter(ram[-3].in-W); permstrings(); Pw=ip; ip += *Pw; } casat() { enter(); if(cptrstack[stkptr+2]) push(TRU); else push(FALS); } semidol() { if(strings[1+strings[1]]=='$') {dropck(); compile(PSEMICOLON); touchup(); } else synterr(); } kernq() { drop(); if(stack[stkptr+1]0) merr(nopen); Pc=stack[1+stkptr]; Pc2=Pc+*Pc-1; while(Pc