perm filename IFN.SAI[S,AIL] blob sn#058518 filedate 1973-08-16 generic text, type T, neo UTF8
COMMENT ⊗   VALID 00006 PAGES 
RECORD PAGE   DESCRIPTION
 00001 00001
 00002 00002	BEGIN "IFN"
 00004 00003	LET DEFINE = REDEFINE
 00005 00004	DEFINE NUMFLGS="12"
 00008 00005	RECURSIVE PROCEDURE DOIFN(INTEGER INSIDE,ONSW,TPAGE
 00013 00006	MAIN LOOP
 00014 ENDMK
⊗;
BEGIN "IFN"
COMMENT  IN A CONDITIONALLY ASSEMBLED FAIL FILE, CLEAN UP
THE TEXT BY REMOVING SECTIONS WHICH ARE UNDER FALSE CONDITIONAL 
ASSEMBLY FLAGS. THE IFN'S SURROUNDING THE TRUE PARTS ARE
ALSO REMOVED.

FOR A FLAG TO BE FOUND, ITS USE MUST BE FORMATTED CORRECTLY.
AS AN EXAMPLE, IN THE FOLLOWING:

GAG < $NEED THIS IN `GOGOL'
	LINE1
	LINE2
	LINE3
>$GAG
NOGAG <$NEED THIS IN `SAIL'
	LINE4
	LINE5
	LINE6
>$NOGAG

WHERE $ MEANS SEMI-COLON, IF GAG IS A MACRO WHICH TESTS
GAGSW TO SEE IF IT IS ON, AND IF WE WANT TO RETAIN `GAG'GED CODE
THE RESULT WOULD BE:

	LINE1
	LINE2
	LINE3

.
IF `GAG'GED CODE WERE TO BE REMOVED, WE WOULD GET THE OTHER THREE
LINES IN THE UPDATED FILE.  
 A CHANGE FILE IS ALSO CREATED, CONTAINING ALL CODE UNDER ANY OF
THESE SWITCHES OR THEIR COMPLEMENTS.;
LET DEFINE = REDEFINE;
DEFINE GOODSWT = "NULL";
DEFINE SWTSIZ = "1";
DEFINE PROCESSOR = """IFN""";
DEFINE SRCEXT = "NULL";
DEFINE RELEXT = """UPD""";
DEFINE LSTEXT = """CHG""";
DEFINE RELMODE = "0";
DEFINE SRCMODE = "0";
DEFINE LSTMODE = "0";
REQUIRE "SCNCMD.SAI[1,DCS]" SOURCE_FILE;
DEFINE NUMFLGS="12";

COMMENT THESE ARE THE NAMES OF THE SWITCHES ;
PRELOAD_WITH "COM2","GAG","EXPO","GLOB","LEP","UP","LOW","GLOC","WOM","SLS","KNT","DIS";
SAFE STRING ARRAY FLAGS[1:NUMFLGS];

COMMENT THESE ARE THE WAYS YOU WOULD LIKE TO HAVE THE SWITCHES SET;
PRELOAD_WITH TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE;
SAFE INTEGER ARRAY STATES[1:NUMFLGS];

COMMENT IF THESE ARE TRUE, THE SWITCH WILL BE IGNORED;
PRELOAD_WITH TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE,FALSE;
INTEGER ARRAY IGNORE[1:NUMFLGS];

PRELOAD_WITH TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,TRUE;

SAFE INTEGER ARRAY CHGS[1:NUMFLGS];

INTEGER I,J,K,LBRSW,RBRSW,ONFLG,PAGENO;
INTEGER SPCL;
STRING LINES,STR,ENDSTR1;

STRING CMPSTR,ST,ST1;

DEFINE SRC="1",UPD="2",CHG="3",CMND="4",DELCHNL="5";
DEFINE TOLINE="1",TOBRCR="2";


PROCEDURE INITIALIZE;
BEGIN
   WANTBIN←WANTLST←TRUE;
	NX_TFIL←FALSE;
   COMMAND_SCAN; "GET COMMAND, OPEN FILE"
   SETBREAK(TOLINE,'12&'14,'15,"IN");
   SETBREAK(TOBRCR,"<"&">",NULL,"I");
 SRCEOF←0;PAGENO←1;
END "INITIALIZE";

PROCEDURE OU(INTEGER CH;STRING LN; INTEGER FL);
 IF FL THEN OUT(CH,LN);
RECURSIVE PROCEDURE DOIFN(INTEGER INSIDE,ONSW,TPAGE;
				STRING ENDSTR);
BEGIN "DOIFN"
NEEDNEXT WHILE ¬SRCEOF DO BEGIN "DOIFN1"
  LABEL SPROULL;

LINES←INPUT(SRC,TOLINE);
NEXT;
SPROULL:
 IF SRCBRK='14 THEN BEGIN "OUT PGMK"
	PAGENO←PAGENO+1;
	OU(UPD,'15&'14,WANTBIN); "WRITE THE FOLLOW-UP"
	OU(CHG,'15&'14,WANTLST); "WRITE THE FOLLOW-UP"
	LINES←INPUT(SRC,TOLINE); "GET ANOTHER "
	NEXT;
	GO TO SPROULL;
 END "OUT PGMK";

 LBRSW←RBRSW←FALSE; ST←LINES;

WHILE LENGTH(ST) DO BEGIN "CHECK NEST"
	ST1←SCAN(ST,TOBRCR,SRCBRK);
	IF SRCBRK = "<" THEN LBRSW←TRUE ELSE
		IF SRCBRK=">" THEN RBRSW←TRUE
END "CHECK NEST";

"LBRSW AND RBRSW HAVE ONLY INITIAL SETTINGS, PENDING FURTHER TESTS"

IF LBRSW ∧ LENGTH(LINES)≥3 THEN BEGIN "CHECK MATCH"

	CMPSTR←LINES;
	WHILE CMPSTR = " " ∨ CMPSTR = '11 DO
		J←LOP(CMPSTR); COMMENT IGNORE LEADING BLANKS, TABS;
	IF EQU(CMPSTR[1 FOR 2],"NO") THEN BEGIN "NO FLAG"
		CMPSTR←CMPSTR[3 TO ∞];
		ONFLG←FALSE
	END "NO FLAG" ELSE ONFLG←TRUE;

	IF (LENGTH(CMPSTR))≥3  THEN
	BEGIN "COULD BE"
		LABEL FOUND, NOFOUND;
		FOR I←1 STEP 1 UNTIL NUMFLGS DO BEGIN
		 K←LENGTH(STR←FLAGS[I]);
		 IF EQU(CMPSTR[1 FOR K],STR) ∧ ¬("A"≤CMPSTR[K+1 FOR 1]≤"Z") 
			THEN IF IGNORE[I] THEN DONE ELSE GO FOUND;
		END;
		LBRSW←FALSE; "ALMOST"
		GO TO NOFOUND;

	  FOUND:
		CMPSTR ←CMPSTR[K+1 TO ∞];
		WHILE CMPSTR= " " ∨ CMPSTR = '11 DO
			J ← LOP(CMPSTR);
		IF CMPSTR = "<" THEN 
			BEGIN J←LOP(CMPSTR);
			      WHILE(CMPSTR= " " ∨ CMPSTR = '11) DO
				J ← LOP (CMPSTR);
			END;
		IF LENGTH(CMPSTR) ∧ CMPSTR ≠";" THEN
			BEGIN OUTSTR ('15&'12&"INVALID LINE PAGE "&CVS(PAGENO));
			      OUTSTR ('15&'12&LINES);
			END;
		ENDSTR1←(IF ONFLG THEN NULL ELSE "NO")&FLAGS[I];
		IF INCHRS≥0 THEN SPCL←TRUE;
		IF SPCL THEN BEGIN OUTSTR(ENDSTR1&"	"&CVS(ONSW)&"	"&CVS(INSIDE)); INCHWL END;
	  NOFOUND:
	END "COULD BE"

	ELSE LBRSW←FALSE;

END "CHECK MATCH" ELSE LBRSW←FALSE;

IF RBRSW∧LENGTH(LINES)≥LENGTH(ENDSTR)+2 ∧LENGTH(ENDSTR) THEN 
BEGIN "CHECK END"
	LABEL BRKT;
	IF SPCL THEN OUTSTR('15&'12&LINES);
	BRKT:
	CMPSTR←LINES;
	WHILE CMPSTR=" " ∨ CMPSTR = '11 DO J←LOP(CMPSTR);
	IF ¬LENGTH(ENDSTR) ∨ LENGTH(CMPSTR)<LENGTH(ENDSTR)+2 
	    ∨ CMPSTR ≠ ">"	THEN RBRSW ← FALSE ELSE
		BEGIN J←LOP(CMPSTR);
		      WHILE CMPSTR = " " ∨ CMPSTR = '11 DO
				J←LOP(CMPSTR);
		      IF CMPSTR ≠ ";" THEN RBRSW ← FALSE
			ELSE BEGIN J ← LOP(CMPSTR);
				   WHILE CMPSTR = " " ∨ CMPSTR = '11 DO
					J←LOP (CMPSTR);
			           IF ¬EQU(CMPSTR[1 TO LENGTH(ENDSTR)],ENDSTR)
					THEN RBRSW ← FALSE;
			     END;
		END;
END "CHECK END" ELSE RBRSW←FALSE;

IF LBRSW∧RBRSW THEN USERERR(0,0,"THE IMPOSSIBLE HAPPENED");

IF ¬LBRSW∧¬RBRSW∧ONSW THEN 
	OU(UPD,LINES&'15&'12,WANTBIN);


IF ¬LBRSW∧INSIDE ∨ LBRSW∧CHGS[I] THEN
	OU(CHG,(IF LBRSW THEN "YES" ELSE NULL)&LINES&'15&'12,WANTLST);


IF LBRSW THEN DOIFN(CHGS[I],ONSW LAND (ONFLG EQV STATES[I]),PAGENO,ENDSTR1)
ELSE IF RBRSW THEN RETURN;

END "DOIFN1";
IF LENGTH(ENDSTR) THEN
	OUTSTR('15&'12&"UNMATCHED-" &ENDSTR&" PAGE NO. -"&CVS(TPAGE));
END "DOIFN";

COMMENT MAIN LOOP;
ON_ETIME←FALSE;
SPCL←FALSE;
WHILE TRUE DO BEGIN "REPEAT"
	INITIALIZE;
	DOIFN(FALSE,TRUE,0,NULL);
END "REPEAT";

END "IFN"