perm filename EAUX3C.2[EAL,HE]4 blob
sn#708969 filedate 1983-05-01 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00006 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 {$NOMAIN Editor: Aux routines used by addStmnt }
C00031 00003 { Externally defined routines from elsewhere: }
C00034 00004 (* addStmnt: more aux routines: descend,elseTest,restoreCursor,setUpNewStmnt,viaOk *)
C00041 00005 (* addStmnt: aux routines: getEmptyStmnt, getBlkId & flushSemi *)
C00044 00006 (* addStmnt: aux routines: addNSt, addNode, addNEnv *)
C00060 ENDMK
C⊗;
{$NOMAIN Editor: Aux routines used by addStmnt }
(* definition of record types & global variables used by AL *)
const
maxLines = 28;
maxPPLines = 18;
maxBpts = 25;
maxTBpts = 20; (* max could be exceeded by huge case stmnt *)
listinglength = 2000; (* Length of Listingarray *)
type
(* random type declarations for OMSI/SAIL compatibility *)
ascii = char;
atext = text;
byte = 0..255;
(* Here are all the pointer-type definitions. Since the various *)
(* records reference each other so much, we have to put them all here. *)
vectorp = ↑vector;
transp = ↑trans;
strngp = ↑strng;
eventp = ↑event;
framep = ↑frame;
statementp = ↑statement;
varidefp = ↑varidef;
nodep = ↑node;
identp = ↑ident;
tokenp = ↑token;
reswordp = ↑resword;
pdbp = ↑pdb;
envheaderp = ↑envheader;
enventryp = ↑enventry;
environp = ↑environment;
cmoncbp = ↑cmoncb;
messagep = ↑message;
linerecp = ↑linerec;
cursorpp = ↑cursorp;
(* datatype definitions *)
datatypes = (pconstype, varitype, svaltype, vectype, rottype, transtype,
frametype, eventtype, strngtype, labeltype, proctype, arraytype,
reftype, valtype, cmontype, nulltype, undeftype,
dimensiontype, mactype, macargtype, freevartype);
scalar = real;
vector = record refcnt: integer; val: array [1..3] of real end;
trans = record refcnt: integer; val: array [1..3,1..4] of real end;
cstring = packed array [1..10] of ascii;
c4str = packed array [1..4] of ascii;
c5str = packed array [1..5] of ascii;
c20str = packed array [1..20] of ascii;
linestr = packed array [1..130] of ascii;
strng = record
next: strngp;
ch: cstring;
end;
event = record
next: eventp; (* all events are on one big list *)
count: integer;
waitlist: pdbp;
end;
frame = record
vari: varidefp; (* back pointer to variable name & info *)
calcs: nodep; (* affixment info *)
case ftype: boolean of (* frame = true, device = false *)
true: (valid: integer; val, fdepr: transp; dcntr: integer; dev: framep);
false: (mech: integer; case sdev: boolean of
true: (sdest: real); false: (tdest,appr,depr: transp));
(* sdev = true for scalar devices, false for frames *)
end;
(* statement definitions *)
stmntypes = (progtype, blocktype, coblocktype, endtype, coendtype,
fortype, iftype, whiletype, untiltype, casetype,
calltype, returntype,
printtype, prompttype, pausetype, aborttype, assigntype,
signaltype, waittype, enabletype, disabletype, cmtype,
affixtype, unfixtype,
movetype,jtmovetype,operatetype,opentype,closetype,centertype,
floattype, stoptype, retrytype,
requiretype, definetype, macrotype, commenttype, dimdeftype,
setbasetype, wristtype, saytype, declaretype, emptytype,
evaltype, armmagictype);
(* more??? *)
statement = packed record
next, last: statementp;
stlab: varidefp;
exprs: nodep; (* any expressions used by this statement *)
nlines: integer;
bpt,bad: boolean;
case stype: stmntypes of
progtype: (pcode: statementp; errors: integer);
blocktype,
declaretype,
endtype,
coendtype: (bcode, bparent: statementp; blkid: identp;
level, numvars: 0..255; variables: varidefp);
coblocktype: (threads: nodep; nthreads: integer; cblkid: identp);
fortype: (forvar, initial, step, final: nodep; fbody: statementp);
whiletype,
untiltype: (cond: nodep; body: statementp);
iftype: (icond: nodep; thn, els: statementp);
casetype: (index: nodep; range, ncases: integer; caselist: nodep);
stoptype: (cf, clauses: nodep);
cmtype: (oncond: nodep; conclusion: statementp;
deferCm, exprCm: boolean; cdef: varidefp);
end;
(* auxiliary definitions: variable, etc. *)
varidef = packed record
next,dnext: varidefp;
name: identp;
level: 0..255; (* environment level *)
offset: 0..255; (* environment offset *)
dtype: varidefp; (* to hold the dimension info *)
tbits: 0..15; (* special type bits: array = 1, proc = 2, ref = 4 & ? *)
dbits: 0..15; (* for use by debugger/interpreter *)
case vtype: datatypes of
arraytype: (a: nodep);
proctype: (p: nodep);
labeltype,
cmontype: (s: statementp);
mactype: (mdef: statementp);
macargtype: (marg: tokenp);
pconstype: (c: nodep);
dimensiontype: (dim: nodep);
end;
(* definition of the ubiquitous NODE record *)
nodetypes = (exprnode, leafnode, listnode, clistnode, colistnode, forvalnode,
deprnode, viaptnode, apprnode, destnode, byptnode, durnode,
sfacnode, wobblenode, swtnode, nullingnode, wristnode, cwnode,
arrivalnode, departingnode,
ffnode, forcenode, stiffnode, gathernode, cmonnode, errornode,
calcnode, arraydefnode, bnddefnode, bndvalnode,
waitlistnode, procdefnode, tlistnode, dimnode, commentnode,
linearnode, elbownode, shouldernode, flipnode, wrtnode,
loadnode,velocitynode);
exprtypes = ( svalop, (* scalar operators *)
sltop, sleop, seqop, sgeop, sgtop, sneop, (* relations *)
notop, orop, xorop, andop, eqvop, (* logical *)
saddop, ssubop, smulop, sdivop, snegop, sabsop, (* scalar ops *)
sexpop, maxop, minop, intop, idivop, modop,
sqrtop, logop, expop, timeop, (* functions *)
sinop, cosop, tanop, asinop, acosop, atan2op, (* trig *)
vdotop, vmagnop, tmagnop,
vecop, (* vector operators *)
vmakeop, unitvop, vaddop, vsubop, crossvop, vnegop,
svmulop, vsmulop, vsdivop, tvmulop, wrtop,
tposop, taxisop,
transop, (* trans operators *)
tmakeop, torientop, ttmulop, tvaddop, tvsubop, tinvrtop,
vsaxwrop, constrop, ftofop, deproachop, fmakeop, vmkfrcop,
ioop, (* i/o operators *)
queryop, inscalarop,
specop, (* special operators *)
arefop, callop, grinchop, macroop, vmop, adcop, dacop, jointop,
badop,
addop, subop, negop, mulop, divop, absop); (* for parsing *)
leaftypes = pconstype..strngtype;
reltypes = sltop..sgtop;
forcetypes = (force,absforce,torque,abstorque,angvelocity);
node = record
next: nodep;
case ntype: nodetypes of
exprnode: (op: exprtypes; arg1, arg2, arg3: nodep; elength: integer);
leafnode: (case ltype: leaftypes of
varitype: (vari: varidefp; vid: identp);
pconstype: (cname: varidefp; pcval: nodep);
svaltype: (s: scalar; wid: integer);
vectype: (v: vectorp);
transtype: (t: transp);
strngtype: (length: integer; str: strngp) ); (* also used by commentnodes *)
listnode: (lval: nodep);
clistnode: (cval: integer; stmnt: statementp; clast: nodep);
colistnode: (prev: nodep; cstmnt: statementp);
tlistnode: (tok: tokenp);
cmonnode: (cmon: statementp; errhandlerp: boolean);
end;
(* records for parser: ident, token, resword *)
ident = record
next: identp;
length: integer;
name: strngp;
predefined: varidefp;
end;
tokentypes = (reswdtype, identtype, constype, comnttype, delimtype, labeldeftype,
macpartype);
constypes = svaltype..strngtype;
reswdtypes = (stmnttype, filtype, clsetype, decltype, optype, edittype);
filtypes = (abouttype,alongtype,attype,bytype,defertype,dotype,elsetype,
errmodestype,fromtype,handtype,intype,nonrigidlytype,rigidlytype,
sourcefiletype,steptype,thentype,totype,untltype,viatype,
withtype,worldtype,zeroedtype,oftype,wheretype,nowaittype,
ontype,offtype,ppsizetype,collecttype,alltype,lextype,
notype,righttype,lefttype,uptype,downtype,motiontype);
clsetypes = (approachtype,arrivaltype,departuretype,departingtype,durationtype,
errortype,forcetype,forceframetype,forcewristtype,gathertype,
nildeproachtype,nullingtype,stiffnesstype,
torquetype,velocitytype,wobbletype,
cwtype,ccwtype,stopwaittimetype,angularvelocitytype,
respecttype,elbowtype,shouldertype,fliptype,lineartype,
jointspacetype,loadtype);
edittypes = (getcmd,savecmd,insertcmd,renamecmd,startcmd,gocmd,proceedcmd,
stepcmd,sstepcmd,nstepcmd,gstepcmd,executecmd,setcmd,tracecmd,
breakcmd,unbreakcmd,tbreakcmd,definecmd,markcmd,unmarkcmd,
popcmd,atcmd,calibratecmd);
token = record
next: tokenp;
case ttype: tokentypes of
constype: (cons: nodep);
comnttype: (len: integer; str: strngp);
delimtype: (ch: ascii);
reswdtype: (case rtype: reswdtypes of
stmnttype: (stmnt: stmntypes);
filtype: (filler: filtypes);
clsetype: (clause: clsetypes);
decltype: (decl: datatypes);
optype: (op: exprtypes);
edittype: (ed: edittypes) );
identtype: (id: identp);
labeldeftype: (lab: varidefp);
macpartype: (mpar: varidefp);
end;
resword = record
next: reswordp;
length: integer;
name: strngp;
case rtype: reswdtypes of
stmnttype: (stmnt: stmntypes);
filtype: (filler: filtypes);
clsetype: (clause: clsetypes);
decltype: (decl: datatypes);
optype: (op: exprtypes);
edittype: (ed: edittypes);
end;
(* process descriptor blocks & environment record definitions *)
queuetypes = (nullqueue,nowrunning,runqueue,inputqueue,eventqueue,sleepqueue,
forcewait,devicewait,joinwait,proccall);
pdb = packed record
nextpdb,next: pdbp; (* for list of all/active pdb's *)
level: 0..255; (* lexical level *)
mode: 0..255; (* expression/statement/sub-statement *)
priority: 0..255; (* probably never greater than 3? *)
status: queuetypes; (* what are we doing *)
env: envheaderp;
spc: statementp; (* current statement *)
epc: nodep; (* current expression (if any) *)
sp: nodep; (* intermediate value stack *)
cm: cmoncbp; (* if we're a cmon point to our definition *)
mech: framep; (* current device being used *)
linenum: integer; (* used by editor/debugger *)
case procp: boolean of (* true if we're a procedure *)
true: (opdb: pdbp; (* pdb to restore when procedure exits *)
pdef: nodep); (* procedure definition node *)
false: (evt: eventp; (* event to signal when process goes away *)
sdef: statementp); (* first statement where process was defined *)
end;
envheader = packed record
parent: envheaderp;
env: array [0..4] of environp;
varcnt: 0..255; (* # of variables in use ??? *)
case procp: boolean of (* true if we're a procedure *)
true: (proc: nodep);
false:(block: statementp);
end;
enventry = record
case etype: datatypes of
svaltype: (s: scalar);
vectype: (v: vectorp);
transtype: (t: transp);
frametype: (f: framep);
eventtype: (evt: eventp);
strngtype: (length: integer; str: strngp);
cmontype: (c: cmoncbp);
proctype: (p: nodep; penv: envheaderp);
reftype: (r: enventryp);
arraytype: (a: envheaderp; bnds: nodep);
end;
environment = record
next: environp;
vals: array [0..9] of enventryp;
end;
cmoncb = record
running, enabled: boolean; (* cmon's status *)
cmon: statementp;
pdb: pdbp;
evt: eventp;
fbits: integer; (* bits for force sensing *)
oldcmon: cmoncbp; (* for debugger *)
end;
(* definition of AL-ARM messages *)
msgtypes = (initarmscmd,calibcmd,killarmscmd,wherecmd,
abortcmd,stopcmd,movehdrcmd,movesegcmd,
centercmd,operatecmd,movedonecmd,signalcmd,
setccmd,forcesigcmd,forceoffcmd,biasoncmd,biasoffcmd,setstiffcmd,
zerowristcmd,wristcmd,gathercmd,getgathercmd,readadccmd,writedaccmd,
errorcmd,floatcmd,setloadcmd,
armmagiccmd,realcmd,vectorcmd,transcmd);
errortypes = (noerror,noarmsol,timerr,durerr,toolong,featna,
unkmess,srvdead,adcdead,nozind,exjtfc,paslim,nopower,badpot,devbusy,
baddev,timout,panicb,nocart,cbound,badparm);
message = record
cmd: msgtypes;
ok: boolean;
case integer of
1: (dev, bits, n: integer;
(* (dev, bits, n, evt: integer; (* for arm code version *)
evt: eventp;
dur: real;
case integer of
1: (v1,v2,v3: real);
2: (sfac,wobble,pos: real);
3: (val,angle,mag: real);
4: (max,min: real);
5: (error: errortypes));
2: (fv1,fv2,fv3,mv1,mv2,mv3: real); (* may never use these... *)
3: (t: array [1..6] of real);
end;
interr = record
case integer of
0: (i: integer);
1: (err,foo: errortypes);
end;
(* print related records: *)
cursorp = record
cline,ind: integer;
case stmntp: boolean of
true: (st: statementp);
false: (nd: nodep);
end;
linerec = record
next: linerecp;
start,length: integer
end;
listingarray = packed array [0..listinglength] of ascii;
(* global variables *)
var
(* from EDIT *)
listing: listingarray; (* first 150 chars are used by expression editor *)
(* next 40 by header & trailer lines *)
{*} cursorStack: array [1..15] of cursorp; {These are BIG records! }
lbuf: array [1..160] of ascii;
ppBuf: array [1..100] of ascii;
lines: array [1..maxLines] of linerecp; (* what's on the screen + some *)
ppLines: array [1..maxPPLines] of linerecp; (* for page printer *)
marks: array [1..20] of integer;
reswords: array [0..26] of reswordp;
idents: array [0..26] of identp;
macrostack: array [1..10] of tokenp;
curmacstack: array [1..10] of varidefp;
screenheight,dispHeight: integer;
ppBufp,oppBufp,ppOffset,ppSize,nmarks: integer;
lbufp,cursor,ocur,cursorLine,fieldnum,lineNum,findLine,pcLine: integer;
firstDline,topDline,botDline,firstLine,lastLine,curLine: integer;
freeLines,oldLines: linerecp;
sysVars: varidefp;
dProg: statementp;
curBlock, newDeclarations, findStmnt: statementp;
macrodepth: integer;
filedepth, errCount, sCursor: integer;
curChar, maxChar, curFLine, curPage: integer;
nodim, distancedim, timedim, angledim,
forcedim, torquedim, veldim, angveldim: varidefp;
fvstiffdim, mvstiffdim: nodep;
pnode: nodep;
smartTerminal: boolean; (* true = insert/delete, false = redraw line *)
setUp,setExpr,setCursor,dontPrint,outFilep,collect,fParse,sParse,
eofError,endOfLine,backup,expandmacros,flushcomments,checkDims,
shownLine: boolean;
curtoken: token;
file1,file2,file3,file4,file5,outFile: atext;
bpts: array [1..maxBpts] of statementp; (* debugging crap *)
tbpts: array [1..maxTBpts] of statementp;
debugPdbs: array [0..10] of pdbp;
nbpts,ntbpts,debugLevel: integer;
eCurInt: pdbp;
STLevel: integer; (* set by GO *)
singleThreadMode,tSingleThreadMode: boolean;
(* from INTERP *)
inputLine: array [1..20] of ascii;
talk: text; (* for using the speech synthesizer *)
curInt, activeInts, readQueue, allPdbs: pdbp;
sysEnv: envheaderp;
clkQueue: nodep;
allEvents: eventp;
etime: integer; (* used by eval *)
curtime: integer; (* who knows where this will get updated - an ast? *)
stime: integer; (* used for clock queue on 10 *)
msg: messagep; (* for AL-ARM interaction *)
inputp: integer; (* current offset into inputLine array above *)
resched, running, escapeI, iSingleThreadMode: boolean;
msgp: boolean; (* flag set if any messages pending *)
inputReady: boolean;
(* various constant pointers *)
xhat,yhat,zhat,nilvect: vectorp;
niltrans: transp;
gpark, rpark: transp; (* arm park positions *)
(* various device & variable pointers *)
speedfactor: enventryp;
garm: framep;
{ Externally defined routines from elsewhere: }
(* From ALLOC *)
function newNode: nodep; external;
procedure relNode(n: nodep); external;
function newIdent: identp; external;
function newEheader: envheaderp; external;
function newStatement: statementp; external;
(* From IAUX1A *)
function getELev(hdr: envheaderp): integer; external;
(* From EAUX1A *)
procedure pushStmnt(s: statementp; indent: integer); external;
procedure pushNode(n: nodep); external;
(* From EAUX1B *)
procedure appendEnd(s,so: statementp); external;
(* From EAUX1C *)
procedure errPrnt; external;
(* From EAUX2B *)
procedure lastStmnt(i: integer; downp: boolean); external;
(* From ETOKEN *)
procedure getToken; external;
(* From EPUTST *)
procedure putstmnt(s: statementp; indent, plevel: integer); external;
(* From PP *)
procedure ppLine; external;
procedure ppOutNow; external;
procedure ppChar(ch: ascii); external;
procedure pp5(ch: c5str; length: integer); external;
procedure pp10(ch: cstring; length: integer); external;
procedure pp10L(ch: cstring; length: integer); external;
procedure pp20(ch: c20str; length: integer); external;
procedure pp20L(ch: c20str; length: integer); external;
(* From DISP *)
procedure outChar(line,col: integer; ch: ascii; bold: boolean); external;
(* addStmnt: more aux routines: descend,elseTest,restoreCursor,setUpNewStmnt,viaOk *)
procedure descend(st: statementp); external;
procedure descend;
var sp: statementp;
begin
sp := nil;
with st↑ do
case stype of
fortype: sp := fbody;
whiletype: sp := body;
iftype: if els <> nil then sp := els else sp := thn;
cmtype: sp := conclusion;
otherwise begin end; (* nothing to do *)
end;
curLine := curline + 1; (* better than nothing(?) *)
if sp <> nil then
begin pushStmnt(sp,0); descend(sp) end; (* don't worry about cline *)
end;
function elseTest(emptyp: boolean): boolean; external;
function elseTest;
var i,j,l: integer; b: boolean; n: nodep;
begin
b := not emptyp; (* if pointing at empty stmnt then no ELSE possible *)
if b then
begin
l := cursorLine;
if sParse and (cursor <= sCursor) then
begin
cursor := sCursor;
curLine := 0;
descend(cursorStack[sCursor].st);
end
else lastStmnt(1,true); (* back up to previous statement *)
cursorLine := l;
with cursorStack[cursor], st↑ do
if (movetype <= stype) and (stype <= floattype) and (clauses <> nil) then
begin
n := clauses;
while n↑.next <> nil do n := n↑.next; (* find last clause *)
if n↑.ntype = cmonnode then
begin
curLine := cline;
pushNode(n); (* don't worry that .cline fields will be wrong *)
pushStmnt(n↑.cmon,2);
descend(n↑.cmon);
end;
end;
b := true;
i := cursor;
if sParse then j := sCursor else j := 1;
while (i >= j) and b do (* look for an IF with no ELSE *)
begin
with cursorStack[i] do
if stmntp then
if l < cline + st↑.nlines then i := 0 (* inside stmnt *)
else if st↑.stype = iftype then b := st↑.els <> nil;
if b then i := i - 1 else cursor := i;
end;
end;
elseTest := b;
end;
procedure restoreCursor; external;
procedure restoreCursor;
begin
setCursor := true;
curLine := 0;
firstLine := 0;
lastLine := -1;
if not sParse then putStmnt(dprog,0,99) (* write & display new line *)
else
begin
cursor := sCursor - 1;
putStmnt(cursorStack[sCursor].st,0,99);
if cursor < sCursor then cursor := sCursor
end;
setCursor := false;
with cursorStack[cursor] do (* don't point at a proc def node *)
if (not stmntp) and (nd↑.ntype = procdefnode) then cursor := cursor - 1;
end;
procedure setUpNewStmnt(sp: statementp; ind: integer); external;
procedure setUpNewStmnt;
var b: boolean;
begin
setUp := true;
setCursor := false;
curLine := 1;
putStmnt(sp,ind,99); (* see how long we are *)
if sp↑.stype = declaretype then
b := sp↑.variables↑.tbits <> 2 (* don't advance cursor for procedure *)
else b := true;
if b then cursorline := cursorline + sp↑.nlines - 1;
setUp := false;
end;
procedure viaOk(i: integer; clOk: boolean; var viaCl: nodep;
var nextLinep: cursorpp); external;
procedure viaOk;
var n: nodep;
begin
if clOk then
with cursorStack[cursor-i].st↑ do
if (stype = movetype) or (stype = jtmovetype) then
begin
n := clauses;
if i = 1 then
begin
if n <> nextLinep↑.nd then
while n↑.next <> nextLinep↑.nd do n := n↑.next;
end
else
if n <> nil then
while n↑.next <> nil do n := n↑.next;
if n <> nil then
if (n↑.ntype = viaptnode) or (n↑.ntype = byptnode) then viaCl := n;
end;
end;
(* addStmnt: aux routines: getEmptyStmnt, getBlkId & flushSemi *)
function getEmptyStmnt(sp:statementp): statementp; external;
function getEmptyStmnt;
var st: statementp;
begin
st := newStatement;
with st↑ do
begin
stype := emptytype;
last := sp;
bparent := sp; (* so we can also use this for END's & COEND's *)
blkid := nil;
end;
appendEnd(sp,st); (* append an end statement to it *)
st↑.next↑.last := sp;
getEmptyStmnt := st;
end;
function getBlkId: identp; external;
function getBlkId;
var bid: identp;
begin
bid := nil;
getToken; (* get the new block id *)
with curToken do
if ttype = constype then
begin
if cons↑.ltype = strngtype then
begin (* yup - grab the id string *)
bid := newIdent;
bid↑.length := cons↑.length;
bid↑.name := cons↑.str;
end
else
begin
pp20L(' Need a string here ',19); ppLine;
end;
relNode(cons);
end
else backUp := true;
getBlkId := bid;
end;
procedure flushSemi(slabel: varidefp); external;
procedure flushSemi;
var i,j,l: integer;
begin
l := cursorLine - topDline;
if slabel <> nil then l := l - 1;
if l > 0 then
begin (* if needed flush the old ";" from previous line *)
with lines[l]↑ do (* fix up old line *)
begin
j := start;
i := start + length - 1;
end;
while (listing[i] = chr(0)) or (listing[i] = ' ') do i := i - 1;
if listing[i] = ';' then
begin (* flush the old semi-colon *)
listing[i] := ' ';
l := l - firstDline + 1;
if l > 0 then (* see if we need to update screen *)
outChar(l,i-j+1,' ',false);
end;
end;
end;
(* addStmnt: aux routines: addNSt, addNode, addNEnv *)
procedure addNSt(sty: stmntypes; nextLinep: cursorpp; var sp: statementp;
slabel: varidefp; emptyp,stok: boolean;
var nogood,flushp: boolean); external;
procedure addNSt;
var no,np: nodep;
begin
if stOk then
begin
if emptyp then sp := nextLinep↑.st
else
begin
sp := newStatement;
if nextLinep↑.stmntp then (* figure how to add statement *)
begin
sp↑.last := nextLinep↑.st↑.last;
sp↑.next := nextLinep↑.st;
if cursorStack[cursor-1].stmntp then
case cursorStack[cursor-1].st↑.stype of
blocktype: with cursorStack[cursor] do (* add us to block *)
begin
sp↑.next := st;
st↑.last := sp;
with sp↑.last↑ do (* check for start of block *)
if next = st then next := sp else bcode := sp;
st := sp; (* have cursor point to us *)
end;
coblocktype:begin
np := newNode;
with cursorStack[cursor-1].st↑ do
begin
no := threads;
if no = nil then threads := np
else
begin
while no↑.next <> nil do no := no↑.next;
no↑.next := np;
end;
nthreads := nthreads + 1;
end;
with np↑ do
begin
ntype := colistnode;
prev := no;
next := nil;
cstmnt := sp;
end;
cursor := cursor - 1;
curLine := cursorLine - 1;
if slabel <> nil then curLine := curLine - 1;
pushNode(np);
pushStmnt(sp,nextLinep↑.ind+1);
end;
casetype: begin
(* *** later *** *)
end;
end
else
begin
np := newNode;
no := cursorStack[cursor-1].nd;
if no↑.ntype = colistnode then
with np↑ do
begin (* add us to coblock *)
ntype := colistnode;
cstmnt := sp;
next := no;
prev := no↑.prev;
no↑.prev := np;
if prev = nil then sp↑.last↑.threads := np else prev↑.next := np;
sp↑.last↑.nthreads := sp↑.last↑.nthreads + 1;
end
else
begin (* add us to case list *)
(* *** later *** *)
end;
cursorStack[cursor-1].nd := np; (* update cursor position *)
cursorStack[cursor].st := sp;
end
end
else
with cursorStack[cursor-1] do
begin (* add us to case list *)
(* *** later for this case *** *)
end
end;
with sp↑ do
begin
stlab := slabel;
stype := sty;
exprs := nil;
if slabel <> nil then
begin
slabel↑.s := sp;
nlines := 2;
end;
end;
end
else
begin
pp20L(' Can''t have a statem',20); pp10('ent here ',8); errPrnt;
sp := nil;
nogood := true;
flushp := true;
end;
end;
function addNode(nextLinep: cursorpp; slabel:varidefp): nodep; external;
function addNode;
var n,np,no: nodep; l,i: integer;
begin
np := newNode;
np↑.next := nil;
if nextLinep↑.stmntp and (cursorStack[cursor-1].stmntp or
(sParse and (cursor <= sCursor))) then
begin (* need to append a new clause *)
l := cursorLine; (* since calling lastStmnt will change it *)
i := cursor;
if sParse and (cursor <= sCursor) then
begin
cursor := sCursor;
descend(cursorStack[sCursor].st);
end
else lastStmnt(1,true); (* backup to motion stmnt *)
cursorLine := l;
for l := i to cursor do (* update part of cursor stack that was just *)
with cursorStack[l] do (* added to the stack by lastStmnt *)
if stmntp then st↑.nlines := st↑.nlines + 1;
with cursorStack[cursor].st↑ do
begin
n := clauses;
if n = nil then clauses := np
else (* find last clause *)
begin while n↑.next <> nil do n := n↑.next; n↑.next := np end;
end;
if not fparse then flushSemi(slabel);
curLine := cursorLine - 1;
if slabel <> nil then curline := curline - 1;
pushNode(np);
cursorStack[cursor].ind := cursorStack[cursor-1].ind + 2;
end
else
begin (* add us to clause list *)
if nextLinep↑.stmntp then cursor := cursor - 1; (* pop up to node *)
with cursorStack[cursor] do
begin (* fix up cursorStack *)
np↑.next := nd;
no := nd;
nd := np;
end;
with cursorStack[cursor-1].st↑ do
begin (* find where to insert new clause & do it *)
if clauses = no then clauses := np
else
begin
n := clauses;
while (n↑.next <> nil) and (n↑.next <> no) do n := n↑.next;
n↑.next := np; (* either we found it or we're at the end *)
end;
end;
end;
addNode := np;
end;
procedure addNEnv; external;
procedure addNEnv;
var i: integer; envhdr,ep: envheaderp;
begin
i := cursor;
while cursorStack[i].st <> curBlock do i := i - 1;
i := cursorStack[i].cline;
if (curBlock↑.variables = nil) and
(i < cursorLine) and (cursorLine < i + curBlock↑.nlines) then
begin (* need to make a new environment header for pdb *)
envhdr := newEheader;
with envhdr↑ do
begin
parent := eCurInt↑.env;
ep := nil;
while curBlock↑.level < getELev(parent) do
begin (* find our level in environment list *)
ep := parent;
parent := parent↑.parent;
end;
if ep <> nil then ep↑.parent := envhdr; (* splice us into list *)
block := curBlock;
procp := false;
for i := 0 to 4 do env[i] := nil;
varcnt := 0;
end;
end;
end;