-- file: MFInputImpl2.mesa
-- Pascal-to-Mesa translator output, translated at October 31, 1985 4:28:02 pm PST
-- Pavel, October 31, 1985 5:07:14 pm PST


DIRECTORY
  PascalBasic,
  PascalWizardFiles,
  MFTypes, MFRest, 
  MFProcArray,
  MFInteraction,
  MFMemory,
  MFSymbols,
  MFInput;

MFInputImpl2: PROGRAM IMPORTS  MFRest, MFProcArray, MFInteraction, MFMemory, MFSymbols, MFInput EXPORTS MFInput = PUBLIC
BEGIN OPEN  MFRest, PascalBasic, PascalWizardFiles, MFTypes, MFProcArray, MFInteraction, MFMemory, MFSymbols, MFInput;
 GetClearSymbol: PROCEDURE
 = 
BEGIN GetSymbol[];ClearSymbol[CurSym,FALSE]; END;--:691----692:
 CheckEquals: PROCEDURE
 = 
BEGIN IF CurCmd#51  THEN IF CurCmd#77  THEN BEGIN MissingErr[61];
BEGIN HelpPtr←5;HelpLine↑[4]←537;HelpLine↑[3]←538;HelpLine↑[2]←539;
HelpLine↑[1]←540;HelpLine↑[0]←541; END;BackError[]; END; END;--:692----693:
 MakeOpDef: PROCEDURE = 
BEGIN M:CommandCode;P, Q, R:Halfword;
 M←CurMod;GetSymbol[];Q←GetNode[2];Mem[Q]↑.Hh.Lh←CurSym;
Mem[ INT[Q]+1]↑.Int←2242;GetClearSymbol[];WarningInfo←CurSym;GetSymbol[];
P←GetNode[2];Mem[P]↑.Hh.Lh←CurSym;Mem[ INT[P]+1]↑.Int←2243;Mem[P]↑.Hh.Rh←Q;
GetNext[];CheckEquals[];ScannerStatus←5;Q←GetAvail[];Mem[Q]↑.Hh.Lh←0;
R←GetAvail[];Mem[Q]↑.Hh.Rh←R;Mem[R]↑.Hh.Lh←0;
Mem[R]↑.Hh.Rh←ScanToks[16,P,0,0];ScannerStatus←0;
Eqtb↑[WarningInfo].Lh←M;Eqtb↑[WarningInfo].Rh←Q;GetXNext[]; END;--:693
--696:----1031:-- CheckDelimiter: PROCEDURE[LDelim,RDelim: Halfword]
 = 
BEGIN  {IF CurCmd=62  THEN IF CurMod=LDelim  THEN  GOTO Label10;
IF CurSym#RDelim  THEN BEGIN MissingErr[Hash↑[RDelim].Rh];
BEGIN HelpPtr←2;HelpLine↑[1]←787;HelpLine↑[0]←788; END;BackError[];
 END  ELSE BEGIN BEGIN IF Interaction=3  THEN NULL;PrintNl[133];Print[789]; END;
Print[Hash↑[RDelim].Rh];Print[790];BEGIN HelpPtr←3;HelpLine↑[2]←791;
HelpLine↑[1]←792;HelpLine↑[0]←793; END;Error[]; END;EXITS Label10 => NULL}; END;--:1031----1010:
 ScanDeclaredVariable: PROCEDURE RETURNS[ScanDeclaredVariableResult: Halfword] = 
BEGIN  X:Halfword;
H, T:Halfword;L:Halfword; GetSymbol[];X←CurSym;
IF CurCmd#41  THEN ClearSymbol[X,FALSE];
IF Eqtb↑[X].Rh=0  THEN NewRoot[X];H←GetAvail[];Mem[H]↑.Hh.Lh←X;T←H;
{WHILE TRUE DO BEGIN GetXNext[];IF CurSym=0  THEN  GOTO Label30;
IF CurCmd#41  THEN IF CurCmd#40  THEN IF CurCmd=63  THEN--1011:
BEGIN L←CurSym;GetXNext[];IF CurCmd#64  THEN BEGIN BackInput[];
CurSym←L;CurCmd←63; GOTO Label30; END  ELSE CurSym←0; END--:1011
 ELSE  GOTO Label30;Mem[T]↑.Hh.Rh←GetAvail[];T←Mem[T]↑.Hh.Rh;
Mem[T]↑.Hh.Lh←CurSym; END ENDLOOP ;EXITS Label30 => NULL};ScanDeclaredVariableResult←H; END;--:1010
 ScanDef: PROCEDURE = 
BEGIN M:PascalInteger[1..2];N:PascalInteger[0..3];K:PascalInteger[0..150];C:PascalInteger[0..7];R:Halfword;
Q:Halfword;P:Halfword;Base:Halfword;LDelim, RDelim:Halfword;
 M←CurMod;C←0;Mem[49999]↑.Hh.Rh←0;Q←GetAvail[];Mem[Q]↑.Hh.Lh←0;
R←0;--699:--IF M=1  THEN BEGIN GetClearSymbol[];WarningInfo←CurSym;
GetNext[];ScannerStatus←5;N←0;Eqtb↑[WarningInfo].Lh←10;
Eqtb↑[WarningInfo].Rh←Q; END  ELSE BEGIN P←ScanDeclaredVariable[];
FlushVariable[Eqtb↑[Mem[P]↑.Hh.Lh].Rh,Mem[P]↑.Hh.Rh,TRUE];
WarningInfo←FindVariable[P];FlushList[P];
IF WarningInfo=0  THEN--700:--BEGIN BEGIN IF Interaction=3  THEN NULL;
PrintNl[133];Print[548]; END;BEGIN HelpPtr←2;HelpLine↑[1]←549;
HelpLine↑[0]←550; END;Error[];WarningInfo←21; END--:700--;
ScannerStatus←4;N←2;IF CurCmd=61  THEN IF CurMod=3  THEN BEGIN N←3;
GetNext[]; END;Mem[WarningInfo]↑.Hh.B0←20+N;Mem[WarningInfo+1]↑.Int←Q;
 END--:699--;K←N;IF CurCmd=31  THEN--702:--DO LDelim←CurSym;
RDelim←CurMod;GetNext[];
IF(CurCmd=56)AND (CurMod>=2242) THEN Base←CurMod  ELSE BEGIN BEGIN IF
Interaction=3  THEN NULL;PrintNl[133];Print[551]; END;BEGIN HelpPtr←1;
HelpLine↑[0]←552; END;BackError[];Base←2242; END;--703:
DO Mem[Q]↑.Hh.Rh←GetAvail[];Q←Mem[Q]↑.Hh.Rh;Mem[Q]↑.Hh.Lh← INT[Base]+K;
GetSymbol[];P←GetNode[2];Mem[ INT[P]+1]↑.Int← INT[Base]+K;Mem[P]↑.Hh.Lh←CurSym;
IF K=150  THEN Overflow[553,150];K←K+1;Mem[P]↑.Hh.Rh←R;R←P;GetNext[];
 IF CurCmd#79--:703-- THEN EXIT; ENDLOOP;CheckDelimiter[LDelim,RDelim];GetNext[];
 IF CurCmd#31--:702-- THEN EXIT; ENDLOOP;IF CurCmd=56  THEN--704:--BEGIN P←GetNode[2];
IF CurMod<2242  THEN BEGIN C←CurMod;Mem[ INT[P]+1]↑.Int←2242+K;
 END  ELSE BEGIN Mem[ INT[P]+1]↑.Int←CurMod+K;
IF CurMod=2242  THEN C←4  ELSE IF CurMod=2392  THEN C←6  ELSE C←7; END;
IF K=150  THEN Overflow[553,150];K←K+1;GetSymbol[];Mem[P]↑.Hh.Lh←CurSym;
Mem[P]↑.Hh.Rh←R;R←P;GetNext[];IF C=4  THEN IF CurCmd=69  THEN BEGIN C←5;
P←GetNode[2];IF K=150  THEN Overflow[553,150];Mem[ INT[P]+1]↑.Int←2242+K;
GetSymbol[];Mem[P]↑.Hh.Lh←CurSym;Mem[P]↑.Hh.Rh←R;R←P;GetNext[]; END;
 END--:704--;CheckEquals[];P←GetAvail[];Mem[P]↑.Hh.Lh←C;Mem[Q]↑.Hh.Rh←P;
--697:
IF M=1  THEN Mem[P]↑.Hh.Rh←ScanToks[16,R,0,N] ELSE BEGIN Q←GetAvail[];
Mem[Q]↑.Hh.Lh←BgLoc;Mem[P]↑.Hh.Rh←Q;P←GetAvail[];Mem[P]↑.Hh.Lh←EgLoc;
Mem[Q]↑.Hh.Rh←ScanToks[16,R,P,N]; END;
IF WarningInfo=21  THEN FlushTokenList[Mem[22]↑.Int]--:697--;
ScannerStatus←0;GetXNext[]; END;--:696----705:--
--719:----721:-- PrintMacroName: PROCEDURE[A,N: Halfword] = 
BEGIN P, Q:Halfword;
 IF N#0  THEN Print[Hash↑[N].Rh] ELSE BEGIN P←Mem[A]↑.Hh.Lh;
IF P=0  THEN Print[Hash↑[Mem[Mem[Mem[A]↑.Hh.Rh]↑.Hh.Lh]↑.Hh.Lh].Rh] ELSE BEGIN
Q←P;WHILE Mem[Q]↑.Hh.Rh#0 DO Q←Mem[Q]↑.Hh.Rh ENDLOOP ;
Mem[Q]↑.Hh.Rh←Mem[Mem[A]↑.Hh.Rh]↑.Hh.Lh;ShowTokenList[P,0,1000,0];
Mem[Q]↑.Hh.Rh←0; END; END; END;--:721----722:--
END.