perm filename EAUX2D.2[EAL,HE] blob
sn#706563 filedate 1983-04-21 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00003 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 {$NOMAIN Editor: Aux parser routines }
C00006 00003 (* Aux routines: readPPLine & readLine *)
C00012 ENDMK
C⊗;
{$NOMAIN Editor: Aux parser routines }
%include eparse.hdr;
{ Externally defined routines from elsewhere: }
(* From EEXPED *)
function exprEditor(line,lstart,llength,estart: integer;
var elength: integer; off: integer): ascii; external;
(* From EAUX1A *)
procedure out1Line(line,start,length: integer); external;
(* From PP *)
procedure ppGlitch; 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;
procedure ppInt(i: integer); external;
(* From DISP *)
procedure outLine(line,col,start,length: integer); external;
(* Aux routines: readPPLine & readLine *)
procedure readPPLine(off: integer); external;
procedure readPPLine;
var ch: ascii; i,j: integer;
begin
if ppOffset >= ppSize then
begin
ch := listing[1];
ppGlitch; (* so line has room to overflow *)
ppOffset := ppOffset - 1;
listing[1] := ch;
end;
j := dispHeight+ppOffset+1;
if (off = 0) or not smartTerminal then
outline(j,1,1,1); (* put out prompt or echo *)
i := off;
ch := exprEditor(j,1,1,2-off,i,off);
if smartTerminal then (* deboldify it *)
out1Line(j,1,maxchar);
for i := 1 to maxChar do ppBuf[i] := listing[i];
ppBufp := maxChar;
oppBufp := maxChar;
ppLine;
listing[1] := ppBuf[1]; (* fix things up for getToken *)
listing[maxChar+1] := ' ';
end;
procedure readline; external;
procedure readline;
var i: integer;
procedure rdLine(var fi: atext);
var ch: ascii; i,j: integer;
begin
maxchar := 0;
curchar := 1;
if eofError or eof(fi) then
begin
if filedepth >= 1 then
begin (* continue with last file *)
filedepth := filedepth - 1;(* pop up a level *)
ppLine; (* give luser a sense of progress *)
readline; (* try again with popped file *)
end
else
begin (* yow - no file left - complain *)
pp20L('*** End of File enco',20); pp20L('untered while parsin',20);
pp10('g program ',10); ppLine;
eofError := true;
listing[1] := 'E'; (* force parser to give up *)
listing[2] := 'N';
listing[3] := 'D';
listing[4] := ';';
listing[5] := ' ';
maxchar := 5;
end
end
else
begin (* normal case - read in next line *)
if ord(fi↑) = 15B then get(fi); (* readln *)
while (ord(fi↑) = 15B) or (ord(fi↑) = 12B) or (ord(fi↑) = 0) do
begin
if ord(fi↑) = 15B then curFLine := curFLine + 1; (* count blank lines too *)
get(fi);
end;
if ord(fi↑) <> 14B then curFLine := curFLine + 1
else (* new page *)
begin
get(fi); (* skip past page mark (= ff) *)
curPage := curPage + 1;
ppInt(curpage); (* give luser a sense of progress *)
ppChar(' ');
ppOutNow;
curFLine := 1;
end;
if eoln(fi) then readln(fi);
while not eoln(fi) and (maxchar < 129) do
begin
maxchar := maxchar + 1;
read(fi,listing[maxchar]);
if ord(listing[maxchar]) = 11B then (* turn tabs into spaces *)
begin
i := 8*(((maxchar - 1) div 8) + 1);
for j := maxchar to i do listing[j] := ' ';
maxchar := i;
end;
end;
listing[maxchar+1] := ' '; (* always can count on a final blank *)
end;
end;
begin
case filedepth of
0: begin
if sParse then
begin
listing[1] := '*'; (* prompt for more input *)
readPPLine(0);
listing[1] := ' '; (* so getToken ignores prompt char *)
end
else
begin
pp20('End of File encounte',20); pp20('red while reading in',20);
pp10(' program. ',9); ppLine;
endOfLine := true;
maxChar := 0;
curchar := 1;
end
end;
1: rdline(file1);
2: rdline(file2);
3: rdline(file3);
4: rdline(file4);
5: rdline(file5);
end;
shownLine := false;
end;