perm filename EADD7.2[EAL,HE]4 blob sn#712024 filedate 1983-05-26 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00004 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	{$NOMAIN	Editor: aux routines for addStmnt }
C00005 00003	procedure addDeclSt(nextLinep: cursorpp var sp: statementp
C00009 00004	procedure add3Aux (nextLinep: cursorpp var sp: statementp slabel: varidefp
C00012 ENDMK
C⊗;
{$NOMAIN	Editor: aux routines for addStmnt }

%include eedit.hdr;

{ Externally defined routines from elsewhere: }

	(* From ALLOC *)
procedure relStatement(n: statementp);				external;
procedure relVaridef(n: varidefp);				external;

	(* From EAUX1A *)
function makeNVar(vartype: datatypes; vid: identp): varidefp;	external;

	(* From EAUX1C *)
procedure errPrnt;						external;

	(* From EAUX2A *)
procedure makeNewVar(newvar: varidefp);				external;

	(* From EPAR3A *)
procedure assignParse(st: statementp);				external;

	(* From EPAR3C *)
function declarationp: boolean;					external;
function getDeclarations(pdef: boolean; lev: integer;
	 var vo: varidefp; var numvars: integer;
	 function dup(v: varidefp): boolean): varidefp;		external;

	(* From EPAR3D *)
procedure reParse(st: statementp);				external;

	(* From EAUX3C - addStmnt aux routines *)
procedure addNEnv;						external;
procedure addNSt(sty: stmntypes; nextLinep: cursorpp; 
	var sp: statementp; slabel: varidefp; 
	emptyp,stok: boolean; var nogood,flushp: boolean);	external;
procedure setUpNewStmnt(sp: statementp; ind: integer);		external;

	(* From PP *)
procedure relLine(l: linerecp);					external;
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;

function dumDup(v: varidefp): boolean; begin dumDup := false end;
procedure addDeclSt(nextLinep: cursorpp; var sp: statementp;
		    slabel: varidefp; emptyp,stok: boolean;
		    var nogood,flushp: boolean; var lcur: integer); external;
procedure addDeclSt;
 var b: boolean; v,vp,vo: varidefp; i: integer;
 begin
 with cursorStack[cursor-1] do
  b := stmntp and (st↑.stype = blocktype) and stOk;	(* check in a block *)
 if b then
   begin			(* add a new declaration statement *)
   addNSt(declaretype,nextLinep,sp,slabel,emptyp,stok,nogood,flushp);
   addNEnv;
   v := nil;
   v := getDeclarations(false,curBlock↑.level,v,i,dumDup);
   sp↑.numvars := i;			(* remember # of variables *)
   if v = nil then
     begin
     nogood := true;
     sp↑.next↑.last := sp↑.last;	(* splice out bad decl stmnt *)
     if sp↑.last↑.next = sp then sp↑.last↑.next := sp↑.next
      else sp↑.last↑.bcode := sp↑.next;
     relStatement(sp);
     sp := nil;
     end
    else
     begin
     vo := nil;
     while v <> nil do
      begin
      vp := makeNVar(v↑.vtype,v↑.name);
      if vo = nil then sp↑.variables := vp else vo↑.dnext := vp;
      vo := vp;
      with vp↑ do
       begin				(* copy relevant fields *)
       dtype := v↑.dtype;
       tbits := v↑.tbits;
       if odd(tbits) then a := v↑.a	(* copy array bounds *)
	else if tbits = 2 then
	 begin		(* need to do special stuff for procedure??? *)
	 p := v↑.p;				(* copy proc def *)
	 p↑.pname := vp;
	 if p↑.body↑.stype = blocktype then cursorLine := cursorLine + 1;
	 end;
       end;
      makeNewVar(vp);		(* if active block make env entry for var *)
      vp := v↑.dnext;
      relVaridef(v);		(* all done with the duplicate varidef now *)
      v := vp;
      end;
     if cursorstack[2].st <> curBlock then
       begin
       reParse(curBlock);
       lcur := 0;		(* since reParse will update display *)
       end
      else setUpNewStmnt(sp,nextLinep↑.ind);
     end;
   end
  else
   begin
   pp20L(' Can''t have a declar',20); pp10('ation here',10); errprnt;
   nogood := true;
   flushp := true;
   end
 end;

procedure add3Aux (nextLinep: cursorpp; var sp: statementp; slabel: varidefp;
	var emptyp,stok,nogood,labp,flushp: boolean; var lcur: integer); external;
procedure add3Aux;
 begin
 with curToken do
  if ttype = comnttype then
   begin			(* comment *)
(* *** need to check if it should be a statement or clause comment *** *)
   addNSt(commenttype,nextLinep,sp,slabel,emptyp,stok,nogood,flushp);	
   if stOk then
     begin
     sp↑.str := str;		(* copy string pointer *)
     sp↑.len := len;
     sp↑.cbody := nil;
     setUpNewStmnt(sp,nextLinep↑.ind);
     end
   end
  else if endOfLine then
   begin
   if slabel = nil then nogood := not labp;	(* delete the line if empty *)
   end
  else	(* probably an assignment statement or declaration *)
   begin
   backUp := true;
   if declarationp then
     begin
     addDeclSt(nextLinep,sp,slabel,emptyp,stok,nogood,flushp,lcur);
     end
    else if (ttype = identtype) or
	    ((ttype = reswdtype) and (rtype = optype)) then
     begin
     addNSt(assigntype,nextLinep,sp,slabel,emptyp,stok,nogood,flushp);
     if stOk then assignParse(sp);
     end
    else
     begin			(* no good - complain *)
     pp20L(' Can''t make sense of',20); pp20(' inserted text      ',14); errPrnt;
     nogood := true;
     backUp := false;	(* ??? *)
     flushp := true;
     end;
   end;
 end;