Google
 

Trailing-Edge - PDP-10 Archives - BB-4157D-BM - sources/left72.bli
There are 12 other files named left72.bli in the archive. Click here to see a list.


!THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
!  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.

!COPYRIGHT (C) 1972,1977 BY DIGITAL EQUIPMENT CORPORATION
!AUTHOR: T.E. OSTEN
MODULE LEFT(STACK)=
BEGIN

REQUIRE LEXNAM.BLI;


MACRO	LEXEME=		1$,
	META=		2$,
	ALL=		3$,
	ONE=		4$,
	OPTION=		5$,
	LIST=		6$,
	REPEAT=		7$,
	ACTION=		8$,
	TERMINAL=	9$;
STRUCTURE STRING[I]=@(.STRING + .I);
STRUCTURE VECTX[I]=[I](.VECTX+.I);
BIND VECTOR LEXNAME=PLIT(
%0%	PLIT'UNKNOWN?0',
%1%	PLIT'IDENTIFIER?0',
%2%	PLIT'CONSTANT?0',
%3%	PLIT'LITSTRING?0',
%4%	PLIT'STATEMENT END?0',
%5%	PLIT'RELATIONALOP?0',
%6%	PLIT'.NOT.?0',
%7%	PLIT'.AND.?0',
%8%	PLIT'.OR.?0',
%9%	PLIT'.EQV. OR .XOR.?0',
%10%	PLIT'"**" OR "^"?0',
%11%	PLIT'LABEL',
%12%	PLIT'"&"?0',
%13%	PLIT'"("?0',
%14%	PLIT'")"?0',
%15%	PLIT'":" ?0',
%16%	PLIT'","?0',
%17%	PLIT'"$"?0',
%18%	PLIT'"-"?0',
%19%	PLIT'"/"?0',
%20%	PLIT'"+"?0',
%21%	PLIT'"*"?0',
%22%	PLIT'"="?0',
);
!******************************************************************************************************************

BIND LEFTBUILD = 1;
REQUIRE	F72BNF.BLI;		!GENERATE SYNTAX TABLES

GLOBAL BIND LEFTV = 2^24+0^18+22;		!VERSION DATE: 18-SEP-1973

REGISTER R;
MACHOP BLT=#251,TTCALL=#051;
BIND	VECTX	TYPE[0]=	BNFTBL<24,12>,
	VECTX	SUBP[0]=	BNFTBL<12,12>,
	VECTX	NUMBER[0]=	BNFTBL<0,12>,
	VECTX	LEXNUM[0]=	BNFTBL<12,6>;
FORWARD
	CERR,		%(S,N,L)= OUTPUT THE MESSAGE: "CONFLICT IN ",.METANAME[.S]," AT NODE ",.N,
			"WITH LEXEME" .L
			)%
	LEFT;		%(NODE,LAST,NAME)= CHECKS CONFLICTS WITH THE LEFT SON
			OF EACH NODE
			)%
EXTERNAL OUTZ,INIT,OCTOUT,DECOUT;
!******************************************************************************************************************
ROUTINE DEC(N)=
BEGIN
	LOCAL A;
	A_((.N MOD 10)+"0")^29;
	N_.N/10;
	IF .N NEQ 0 THEN DEC(.N);
	TTCALL(3,A)
END;
!******************************************************************************************************************
ROUTINE CERR(S,N,L)=
%(-----------------------------------------------------------------------------------------------------------------
	S=	NUMBER OF THE METANAME STRING FROM THE LAST METASYMBOL
	N=	NODE AT WHICH CONFLICT OCCURED
	L=	LEXEME (OR TERMINAL) WHICH CONFLICTED
		(RESULT OF THE AND)
-----------------------------------------------------------------------------------------------------------------)%
BEGIN
	OUTZ(3,PLIT'%CONFLICT IN ');
	OUTZ(3,.METANAME[.S]);
	OUTZ(3,PLIT' AT NODE ');
	DECOUT(3,4,.N);
	OUTZ(3,PLIT' WITH ');
	VREG_FIRSTONE(.L);
	IF .VREG GTR LASTLEX THEN
	BEGIN
		VREG_.VREG-LASTLEX;
		OUTZ(3,PLIT'ACTION ?0');
		OUTZ(3,.ACTIONNAME[.VREG])
	END
	ELSE
	BEGIN
		OUTZ(3,PLIT'LEXEME ');
		OUTZ(3,.LEXNAME[.N])
	END;
	OUTZ(3,PLIT'%?M?J');
	R_.R+1
END;
!******************************************************************************************************************
BIND VECTOR TFIELD=PLIT(
%1%	PLIT'LEXEME',
%2%	PLIT'META',
%3%	PLIT'ALL',
%4%	PLIT'ONE',
%5%	PLIT'OPTION',
%6%	PLIT'LIST',
%7%	PLIT'REPEAT',
%8%	PLIT'ACTION',
%9%	PLIT'TERMINAL')-1;
OWN VECTOR LEFTLEX[LLSIZE],RIGHT,LEX,TRACE,START;
%(-----------------------------------------------------------------------------------------------------------------
	LEFTLEX=A BIT MASK OF THE LEXEMES COMPRISING THE LEFT SON OF EACH
		NODE IN THE BNF TABLE.
	RIGHT=	THE RIGHT BROTHER OF THE CURRENT SON OF AN ALL.
	LEX=	THE RESULT OF A LEXEME CONFLICT CHECK.
-----------------------------------------------------------------------------------------------------------------)%
ROUTINE TYPEOUT(N)=
!------------------------------------------------------------------------------------------------------------------
!	N= NODE TO BE TYPED
!
!TYPES: NODE(.N)= .TYPE, .SUBP, .NUMBER - .LEFTLEX
!------------------------------------------------------------------------------------------------------------------
BEGIN
	OUTZ(3,PLIT'NODE(');DECOUT(3,4,@N);OUTZ(3,PLIT')= ');
	OUTZ(3,.TFIELD[.TYPE[@N]]);
	OUTZ(3,PLIT', ');DECOUT(3,4,.SUBP[@N]);OUTZ(3,PLIT', ');
	IF .TYPE[@N] EQL LEXEME OR .TYPE[@N] EQL META THEN OUTZ(3,.METANAME[.NUMBER[@N]])
		ELSE DECOUT(3,4,.NUMBER[@N]);
	IF @LEFTLEX[@N] NEQ 0 THEN
	BEGIN
		OUTZ(3,PLIT'?M?J	');
		INCR I FROM -35 TO 0 DO
		BEGIN
			IF @LEFTLEX[@N]^@I THEN OUTZ(3,PLIT'X') ELSE OUTZ(3,PLIT'O');
			IF (.I MOD 3) EQL 0 THEN OUTZ(3,PLIT' ')
		END;
	END;
	OUTZ(3,PLIT'?M?J')
END;
!******************************************************************************************************************
ROUTINE DECIN=
BEGIN
	REGISTER R1,R2;
	R1_R2_0;
	UNTIL (TTCALL(4,R1);.R1) EQL #015 OR .R1 EQL #012 DO
		R2_(.R2*10)+(.R1-"0");
	.R2
END;
!******************************************************************************************************************
ROUTINE LEFT(NODE,LAST,NAME)=
%(-----------------------------------------------------------------------------------------------------------------
	NODE=	THE CURRENT LOCATION IN THE BNF TABLE (BNFTBL).
	LAST=	THE IGHT BROTHER OF THE CURRENT NODE AT THE LAST ALL.
		INITIALLY SET TO ZERO.
	NAME=	LOCATION IN THE METANAME TABLE OF THE LAST META.
-----------------------------------------------------------------------------------------------------------------)%
BEGIN
	LOCAL SON;
	IF .TRACE THEN (OUTZ(3,PLIT'BEGIN - ');TYPEOUT(@NODE));
	CASE .TYPE[@NODE] OF SET
%CASE 0%		EXITCASE;
%CASE 1-LEXEME%	LEFTLEX[@NODE]_1^.LEXNUM[@NODE];
%CASE 2-META%	BEGIN
			IF .LEFTLEX[.SUBP[@NODE]] EQL 0 THEN
			BEGIN
				LEFTLEX[.SUBP[@NODE]]<35,1>_1;	!INDICATE NODE ALREADY SEEN
				LEFT(.SUBP[@NODE],@LAST,.NUMBER[@NODE]);
			END;
			LEFTLEX[@NODE]_@LEFTLEX[.SUBP[@NODE]];
		END;
%CASE 3-ALL%	BEGIN
			RIGHT_@LAST;
			SON_.SUBP[@NODE]+.NUMBER[@NODE]+1;
			WHILE (SON_.SON-1) GEQ .SUBP[@NODE] DO
			BEGIN
				LEFT(@SON,@RIGHT,@NAME);
				RIGHT_@SON
			END;
			WHILE (SON_.SON+1) LEQ .SUBP[@NODE]+.NUMBER[@NODE] DO
			BEGIN
				LEFTLEX[@NODE]_@LEFTLEX[@NODE] OR @LEFTLEX[@SON];
				IF .TYPE[@SON] NEQ OPTION THEN EXITLOOP	
			END;
			LEFTLEX[@NODE]_@LEFTLEX[@NODE] OR @LEFTLEX[@SON];
		END;
%CASE 4-ONE%	BEGIN
			SON_.SUBP[@NODE]+.NUMBER[@NODE]+1;
			WHILE (SON_.SON-1) GEQ .SUBP[@NODE] DO
			BEGIN
				LEFT(@SON,@LAST,@NAME);
				IF (LEX_@LEFTLEX[@NODE] AND @LEFTLEX[@SON] AND NOT 1^35) NEQ 0
					THEN CERR(@NAME,@NODE,.LEX);
				LEFTLEX[@NODE]_@LEFTLEX[@NODE] OR @LEFTLEX[@SON];
			END;
		END;
%CASE 5-OPTION%	BEGIN
			SON_.SUBP[@NODE]+.NUMBER[@NODE]+1;
			WHILE (SON_.SON-1) GEQ .SUBP[@NODE] DO
			BEGIN
				LEFT(@SON,@LAST,@NAME);
				IF (LEX_@LEFTLEX[@NODE] AND @LEFTLEX[@SON] AND NOT 1^35) NEQ 0
					THEN CERR(@NAME,@NODE,.LEX);
				LEFTLEX[@NODE]_@LEFTLEX[@NODE] OR @LEFTLEX[@SON];
			END;
		END;
%CASE 6-LIST%	BEGIN
			LEFT(.SUBP[@NODE],@LAST,@NAME);
			LEFTLEX[@NODE]_@LEFTLEX[.SUBP[@NODE]];
		END;
%CASE 7-REPEAT%	BEGIN
			LEFT(.SUBP[@NODE],@LAST,@NAME);
			LEFTLEX[@NODE]_@LEFTLEX[.SUBP[@NODE]];
			RIGHT_IF @LAST NEQ 0 THEN @LEFTLEX[@LAST] ELSE 0;
			IF (LEX_@LEFTLEX[@NODE] AND @RIGHT AND NOT 1^35) NEQ 0
				 THEN CERR(@NAME,@NODE,@LEX);
		END;
%CASE 8-ACTION%	LE