perm filename EADD4.2[EAL,HE]1 blob sn#674839 filedate 1982-09-27 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	{$NOMAIN	Editor: aux routines for addStmnt }
C00004 00003	procedure add1Aux (var l,lcur: integer nextLinep: cursorpp var sp: statementp
C00008 ENDMK
C⊗;
{$NOMAIN	Editor: aux routines for addStmnt }

%include eedit.hdr;

{ Externally defined routines from elsewhere: }

	(* From EAUX1A *)
procedure pushStmnt(s: statementp; indent: integer);		external;

	(* From ETOKEN *)
procedure eGetToken;						external;

	(* From EAUX2B *)
procedure lastStmnt(i: integer; downp: boolean);		external;

	(* From EAUX2C *)
procedure insertLines(start,number,coff: integer);		external;

	(* From EAUX3C - addStmnt aux routines *)
function getEmptyStmnt(sp:statementp): statementp;		external;
procedure flushSemi(slabel: varidefp);				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;

procedure add1Aux (var l,lcur: integer; nextLinep: cursorpp; var sp: statementp;
	var slabel: varidefp; var emptyp,stok,clok,nogood,labp: boolean); external;
procedure add1Aux;
 var i: integer; b: boolean;
 begin
 with eCurToken do 
  if ttype = labeldeftype then
    begin                     (* a label *)
    slabel := lab;            (* copy pointer to label *)
    cursorLine := cursorLine + 1;
    eGetToken;                        (* move on to start of new statement? *)
    if not endOfLine then lcur := lcur + 1;
    b := (((rtype = filtype) and (filler = defertype)) or
	  ((rtype = stmnttype) and (stmnt = cmtype)));
    if not (stOk or nextLinep↑.stmntp or (clOk and (ttype = reswdtype) and b)) then
      begin
      pp20L(' Can''t have a label ',20); pp5('here ',4); ppLine;
      if endOfLine then nogood := true;       (* maybe there's something else? *)
      end
    end
   else if (ttype = delimtype) and (ch = '[') then
    begin                     (* a case label *)
  (* *** worry about this case later *** *)
    end
   else if (ttype = reswdtype) and (rtype = filtype) then
    if filler = elsetype then
      begin (* must be after an if-then with no else, or in a labelled case stmnt *)
  (* *** code to handle labelled case case *** *)
      l := cursorLine;
      lastStmnt(1,true);              (* back up to previous statement *)
      cursorLine := l;
      b := true;
      i := cursor;
      while (i > 1) 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;
       end;
      if not b then
	begin                 (* add an empty statement *)
	flushsemi(slabel);
	sp := cursorStack[i].st;
	sp↑.nlines := sp↑.nlines + 1;
	sp↑.els := getEmptyStmnt(sp);
	sp := sp↑.els;
	cursor := i;
	curline := cursorLine;        (* & update cursor stack *)
	pushStmnt(sp,2);
	nextLinep↑.st := sp;
	nextLinep↑.stmntp := true;
	sp := nil;
	lcur := lcur + 1;
	cursorLine := cursorLine + 1;
	insertLines(cursorLine,1,1);
	emptyp := true;
	stOk := true;
	clOk := false;
	end;
      labp := not b;
      if b then
	begin
	pp20L(' Can''t have an "ELSE',20); pp10('" here    ',6); ppLine;
	nogood := true;
	end
       else eGetToken;
      end
     else if filler = thentype then
      begin
  (* *** must be after a deproach or via clause *** *)
      end;
 end;