Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-02 - 43,50227/kwic.mac
There are 5 other files named kwic.mac in the archive. Click here to see a list.
	COMMENT	>
*****************************************************************
*****************************************************************
*****************************************************************
*								*
*								*
*								*
*								*
*								*
*			K----W----I----C			*
*								*
*			     1----0				*
*								*
*		WRITTEN BY					*
*			G.B. MOERSDORF				*
*								*
*								*
*								*
*								*
*								*
*****************************************************************
*****************************************************************
*****************************************************************
>
	PAGE
	TITLE	KWIC
	SUBTTL	GERRY MOERSDORF, OHIO STATE UNIVERSITY PDP-10

	COMMENT *
    THIS ROUTINE DOES A SINGLE KEY-WORD-IN-CONTEXT
(KWIC) INDEX.  THE SYSTEM ALLOWS ANY ARRANGMENT OF I/O DEVICES
AND ANY TYPE OF MASTER FILE DATA.  THE STOP LIST MAY BE
ADDED TO AND EDITED IN ANY WAY TO SUITE THE
USER'S NEEDS.  MANY PARAMETERS ARE ASKED FOR BUT ALL WILL
DEFAULT IF THE USER TYPES A (CR).  THE PARAMETERS ARE AS FOLLOWS
AND ALL ARE ENTERED IN THE FORM 'DEV:FILE.EXT':

MASTER FILE:	THE FILE WHERE THE RECORDS TO BE
			INDEXED ARE

		[DEFAULT]---KWIC.MAS  (KWIC MASTER)

STOP FILE:	THE FILE CONTAINING THE WORDS NOT VALID AS KEY WORDS

		[DEFAULT]---KWIC.STP   (KWIC STOP)

INDEX FILE:	THE FILE WHERE THE INDEX IS TO BE WRITTEN

		[DEFAULT]---KWIC.NDX   (KWIC INDEX)

FREQUENCY FILE:	THE FILE WHERE THE FREQUENCY LISTING IS TO
			BE WRITTEN

		[DEFAULT]---KWIC.FRQ	(KWIC FREQUENCY)

LISTING TITLE: 	THE TITLE OF THE LISTING (80 CARS OR LESS)

		[DEFAULT]---NO TITLE


	EDIT HISTORY

[1]	USE MASTER INPUT FILE NAME AS DEFAULT NAME FOR THE
	.FRQ AND .NDX OUTPUT FILES.  HD TODD, 21 OCT 77, WESLEYAN UNIV.
[2]	IF THE .STP FILE CANNOT BE FOUND ON THE USER'S AREA, LOOK IN THE
	PPN AREA FROM WHICH THE PROGRAM WAS RUN.  THIS FACILITATES USE OF
	THE KWIC PROGRAM AS A LIBRARY PROGRAM WITH A STANDARD STOP FILE.
	HD TODD, 21 OCT 77, WESLEYAN UNIVERSITY.


*
	PAGE
	;ACCUMULATOR DEF'S

	AC=1
	CAR=2
	INDEX=3
	F=4
	P=5
	CNT1=6
	TITL=7
	CNT2=17
	PTR=10
	PTR2=11
	TAC=12
	ARG=13
	FILE=14
	EXT=15
	PAGE=EXT
	PPN=17
	DATE=16
	PAGE
	;FLAGS AND CONSTANTS

	F.LRG==10		;LINE TOO LONG
	F.ECO==200		;SO AS NOT TO MAKE TOO MUCK PAPER
	F.SYN==400000		;SYNTAX ERROR HAS OCCURED
	F.NOK==20000		;NO KEY ENTERED
	F.NPE==40000		;NO PERIOD SEEN
	F.PER==100		;PERIOD SEEN IN COMMAND
	F.BEG==400		;BEGINING SECTOR OF SCAN
	F.OUT==40		;QUIT AFTER MASTER READ IN SWITCH
	F.NST==1		;NO STORE
	F.EOI==2		;PERIOD SEEN
	F.BRK==4		;BRACKET SEEN
	F.FRQ==20		;FREQUENCY LIST MODE
	STKSIZ==^D30		;SIZE OF PUSH DOWN STACK
	MASCH==1		;CHANEL FOR MASTER FILE
	STPCH==2		;CHANNEL FOR STOP FILE
	NDXCH==3		;CHANNEL FOR INDEX LISTING
	FRQCH==4		;CHANEL FOR FREQ LIST
	IB==10			;IMAGE BINARY MODE
	AL==1			;ASCII LINE MODE
	CORE==11		;CORE UUO
	SLEEP==31		;SLEEP UUO
	JOBFF==121		;JOB FIRST FREE
	VERSION==1		;VERSION NUMBER
	JOBVER==137		;PLACE TO PUT VERSION NUMBER
	UTIME==22		;TIME IN JIFFYS
	UDATE==14		;DATE UUO NUMBER
	IFNDEF SIZWRD,<SIZWRD==^D50>	;SIZE OF LARGEST WORD
	SIZSTP==SIZWRD/6+2		;SIXBIT BUT 1 WORK WORD USED
	IFNDEF IDLEN,<IDLEN=^D10>	;LENGTH OF I.D. FIELD
	MAXKEY=IDLEN+1		;1 EXTRA FOR DELIMITER
	IFNDEF MAXSAM,<MAXSAM==^D300>	;MAX NUMBER OF ITEMS SAME
	IFNDEF DEBUG,<DEBUG==0>	;ONE TO DEBUG
	IFN DEBUG,<REENT==0>	;IF DEBUGING MAKE NON REENT
	IFNDEF REENT,<REENT==1>	;DEFAULT RENTRANT VERSION
	IFNDEF DELSRT,<DELSRT=="=">	;DEFAULT FOR SORT DELIM
	IFNDEF DELKEY,<DELKEY=="[">	;DEFAULT FOR ID. NUMBER DELIM
	IFNDEF DELEOL,<DELEOL=="]">	;END OF LINE DEFAULT
	IFNDEF LPTSIZ,<LPTSIZ==^D132>	;SIZE OF LINE PRINTER
	IFNDEF MAXLIN,<MAXLIN==^D50>	;LINES PER PAGE
	IFNDEF	FREQSW,<FREQSW==1>	;INCLUDE FREQ LIST CODE IF 1

	LOC	JOBVER
	XWD	0,VERSION		;SET UP VERSION NUMBER
	RELOC
	PAGE
	;STARTS HERE

	IFN	REENT<HISEG>
START:	CALLI	0,0
	MOVEM	7,SRCPPN	;[2]SAVE PPN FROM WHICH PROGRAM RAN
	MOVEM	11,SRCDEV	;[2]SAVE DEV: FROM WHICH PROGRAM RAN
	MOVE	P,[IOWD STKSIZ,STACK]
	SETZB	F,ZERLST
	MOVE	PTR,[XWD ZERLST,ZERLST+1]
	BLT	PTR,ELST		;CLEAR OUT LOW SEGMENT
	MOVE	AC,JOBFF
	MOVEM	AC,EPROG1
	TTCALL	3,[ASCIZ/
KEY-WORD-IN-CONTEXT
/]
CONT5:	TTCALL	3,[ASCIZ/
MASTER FILE: /]
	PUSHJ	P,SETFIL
	MOVSI	EXT,'MAS'
	PUSHJ	P,SETCMD
	MOVEM	CAR,MASDEV
	MOVEI	AC,IB
	SETZ	INDEX,
	OPEN	MASCH,AC
	JRST	NMAS
	MOVEM	FILE,MAFIL
	MOVEM	EXT,MAFIL+1
	LOOKUP	MASCH,FILE
	JRST	NMASFI
CONT4:
	TTCALL	3,[ASCIZ/STOP FILE: /]
	PUSHJ	P,SETFIL
	MOVSI	EXT,'STP'
	PUSHJ	P,SETCMD
	MOVEI	AC,IB
	HRRZI	INDEX,STPBUF
	OPEN	STPCH,AC
	JRST	NSTP
	LOOKUP	STPCH,FILE	;FIRST, LOOK ON THE USER'S AREA
	SKIPA			;[2]NO LUCK - TRY AGAIN
	JRST	CONT3		;[2]
	MOVE	CAR,SRCDEV	;[2]
	OPEN	STPCH,AC	;[2]USE ERSATZ DEVICE OF PROGRAM
	JRST	NSTP
	MOVE	PPN,SRCPPN	;[2]TRY LOOKING WHERE THE PROGRAM RAN FROM
	LOOKUP	STPCH,FILE	;[2]
	JRST	NSTPFI		;GIVE UP HOPE
CONT3:
	TTCALL	3,[ASCIZ/INDEX FILE: /]
	PUSHJ	P,SETMAS	;[1]
	MOVSI	EXT,'NDX'
	PUSHJ	P,SETCMD
	MOVEI	AC,AL
	HRLZI	INDEX,NDXBUF
	OPEN	NDXCH,AC
	JRST	NNDX
	ENTER	NDXCH,FILE
	JRST	NNDXF
	OUTBUF	NDXCH,3
	IFN	FREQSW,
<
CONT2:	TTCALL	3,[ASCIZ/FREQUENCY FILE: /]
	PUSHJ	P,SETMAS	;[1]
	MOVSI	EXT,'FRQ'
	PUSHJ	P,SETCMD
	MOVEI	AC,AL
	HRLZI	INDEX,FRQBUF
	OPEN	FRQCH,AC
	JRST	NFRQ
	ENTER	FRQCH,FILE
	JRST	NFRQF
	OUTBUF	FRQCH,2
>
	MOVE	AC,JOBFF
	MOVEM	AC,STSTP
	INBUF	STPCH,3
	TTCALL	3,[ASCIZ/LISTING TITLE:
/]
	TTCALL	4,AC
	MOVE	PTR,[POINT 7,TITLE]
LOOP7:	IDPB	AC,PTR
	TTCALL	0,AC
	CAIE	AC,12
	JRST	LOOP7
	SETZ	AC,
	IDPB	AC,PTR
	PAGE
	;READ INTO CORE ROUTINE
	MOVE	AC,JOBFF
	MO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CAR,ARG
	JUMPE	CAR,CPOPJ1
	PUSHJ	P,NDXPUT
	JRST	LOOPR
CPOPJ1:	POPJ	P,0


;SET UP SEQUENCE NUMBER SUBROUTINE

SETSEQ:	MOVEM	CAR,CURLIN
	PUSHJ	P,GETMAS
	IBP	PTR2
	JRST	CONT41


;ROUTINE TO PRINT OUT ERROR MESSAGES

ERROR:	TTCALL	3,[ASCIZ/?ERROR IN LINE /]
	TRO	F,F.OUT
	SETZM	CURLIN+1
	TTCALL	3,CURLIN
	TRZE	F,F.LRG
	TTCALL	3,[ASCIZ/---I.D. NUMBER TOO LONG/]
	TRZE	F,F.NOK
	TTCALL	3,[ASCIZ/---NO I.D. NUMBER FOUND/]
	TRZE	F,F.NPE
	TTCALL	3,[ASCIZ/---NO SORT DELIM FOUND/]
	TRZE	F,F.SYN
	TTCALL	3,[ASCIZ/---SYNTAX ERROR/]
	TTCALL	3,[ASCIZ/
/]
	POPJ	P,0


;ROUTINE TO ALLOCATE ONE WORD OF CORE AND UPDATE JOBFF

ALLOC:	PUSHJ	P,SETTAC
	CALLI	TAC,CORE
	JRST	SLEP
	PUSHJ	P,SETTAC
	MOVEM	TAC,JOBFF
	POPJ	P,0
SLEP:	MOVEI	TAC,^D30
	TTCALL	3,[ASCIZ/?CORE UUO FAILED--TRYING AGAIN
/]
	CALLI	TAC,SLEEP
	JRST	ALLOC
SETTAC:	MOVE	TAC,JOBFF
	AOS	TAC
	POPJ	P,0


;ROUTINE TO SET UP 'PARSE' THE COMMAND STRING

SETCMD:	TTCALL	4,AC
	TLZ	F,F.PER!F.BRK
RESET:	MOVEI	CNT1,6
	SETZ	TAC,
	MOVE	PTR,[POINT 6,TAC]
LOOPA:	PUSHJ	P,CODCHK
	TLO	F,F.BRK
	SUBI	AC,40
	IDPB	AC,PTR
	TTCALL	0,AC
	SOJG	CNT1,LOOPA
ZAP:	PUSHJ	P,CODCHK
	TTCALL	0,AC
	JRST	ZAP
CODCHK:	CAIN	AC,":"
	JRST	PUTDEV
	CAIN	AC,"."
	JRST	PUTFIL
	CAIN	AC,15
	JRST	EXTP
	POPJ	P,0
PUTDEV:	MOVE	CAR,TAC
	POP	P,0
LOOPB:	TTCALL	0,AC
	JRST	RESET
PUTFIL:	TLO	F,F.PER
	POP	P,0
	MOVE	FILE,TAC
	JRST	LOOPB
EXTP:	TLNN	F,F.BRK
	JRST	CPOP
	TLNN	F,F.PER
	SKIPA	FILE,TAC
	MOVE	EXT,TAC
CPOP:	POP	P,0
	TTCALL	0,AC
	POPJ	P,0


;ROUTINE TO OUTPUT SIXBIT ON LPT

SIXOUT:	MOVEI	TAC,6
	MOVE	TITL,[POINT 6,ARG]
LOOPT:	ILDB	CAR,TITL
	ADDI	CAR,40
	PUSHJ	P,NDXPUT
	SOJG	TAC,LOOPT
	POPJ	P,0
	PAGE
	;ERROR MESSAGES


TOBIG:	TTCALL	3,[ASCIZ/?MAXIMUM SIZE WORD EXCEEDED/]
PWRD:	TTCALL	3,[ASCIZ/
WORD=/]
	MOVE	PTR,[POINT 6,OLDMAX]
	SETZM	OLDMAX+SIZSTP-1
CRLOP:	ILDB	CAR,PTR
	JUMPE	CAR,CRASH
	ADDI	CAR,40
	TTCALL	1,CAR
	JRST	CRLOP
CRASH:	MOVE	AC,EPROG1
	MOVEM	AC,JOBFF
	CALLI	0
	CALLI	12
LOTS:	TTCALL	3,[ASCIZ/?TOO MANY MATCHES FOR ARRAY/]
	JRST	PWRD
ENDRUN:	TTCALL	3,[ASCIZ/
INDEX COMPLETE
TOTAL CORE USED /]
	IFN	REENT,<
	SEGSIZ==<EHGH-START>/2000+61
>
	IFE	REENT,<		;FANCY CODING TO MAKE RENTRANT AND
	SEGSIZ==60		;NON RENTRANT CORE NUMBERS CORRECT
>
	MOVEI	AC,SEGSIZ
	TTCALL	1,AC
	MOVEI	AC,"+"
	TTCALL	1,AC
	MOVE	AC,JOBFF
	PUSHJ	P,PCORE
	RELEASE	MASCH,
	RELEASE	NDXCH,
	IFN	FREQSW,
<
	RELEASE	FRQCH,0
>
	JRST	CRASH
WOW:	TTCALL	3,[ASCIZ/?MASTER FILE NO LONGER AVAILABLE/]
	JRST	CRASH
NNDX:	TTCALL	3,[ASCIZ/CANNOT INIT INDEX DEVICE
/]
	JRST	CONT3
NSTP:	TTCALL	3,[ASCIZ/CANNOT INIT STOP LIST DEVICE
/]
	JRST	CONT4
NMAS:	TTCALL	3,[ASCIZ/CANNOT INIT MASTER DEVICE
/]
	JRST	CONT5
NMASFI:	TTCALL	3,[ASCIZ/CANNOT FIND MASTER FILE
/]
	JRST	CONT5
NNDXF:	TTCALL	3,[ASCIZ/CANNOT ENTER INDEX FILE
/]
	JRST	CONT3
NSTPFI:	TTCALL	3,[ASCIZ/CANNOT FIND STOP FILE
/]
	JRST	CONT4
SETFIL:	MOVE	FILE,[SIXBIT/KWIC/]
	SETZB	PPN,DATE
	MOVSI	CAR,'DSK'
	POPJ	P,0
SETMAS:	MOVE	FILE,MAFIL	;[1] ADD THIS SECTION TO SET MASTER FILE
	SETZB	PPN,DATE	;     NAME AS DEFAULT OUTPUT FILE NAME
	MOVSI	CAR,'DSK'
	POPJ	P,
BADFAL:	TTCALL	3,[ASCIZ/?FATAL UUO FAILURE -BADFAL-/]
	CALLI	0
	CALLI	12
CARPT:	POINT	7,CAR
STPGET:	SOSG	STPBUF+2
	JRST	STPIN
STPNXT:	ILDB	CAR,STPBUF+1
	POPJ	P,0
STPIN:	IN	STPCH,0
	JRST	STPNXT
	STATZ	STPCH,740000
	SKIPA
	JRST	STPEOF
	TTCALL	3,[ASCIZ/
?READ ERROR ON STOP LIST/]
	JRST	CRASH
GETMAS:	SOSG	MASBUF+2
	JRST	MASIN
MASNXT:	ILDB	CAR,MASBUF+1
	POPJ	P,0
MASIN:	IN	MASCH,0
	JRST	MASNXT
	STATZ	MASCH,740000
	SKIPA
	JRST	MASEOF
	TTCALL	3,[ASCIZ/
?READ ERROR ON MASTER FILE/]
	JRST	CRASH
NDXPUT:	TRNE	F,F.FRQ
	JRST	FRQPUT
	SOSG	NDXBUF+2
	JRST	NDXOUT
NDXNXT:	IDPB	CAR,NDXBUF+1
	POPJ	P,0
NDXOUT:	OUT	NDXCH,0
	JRST	NDXNXT
	TTCALL	3,[ASCIZ/
?WRITE ERROR ON INDEX FILE/]
	JRST	CRASH
NDXTIL:	ASCIZ/KWIC INDEX---/
	IFN	FREQSW,
<
FRQTIL:	ASCIZ/FREQUENCY LIST---/
NFRQ:	TTCALL	3,[ASCIZ/CANNOT INIT FREQUENCY DEVICE
/]
	JRST	CONT2
NFRQF:	TTCALL	3,[ASCIZ/CANNOT ENTER FREQUENCY FILE
/]
>
STOP:	OCT	-1
	XLIST		;JUST LITS HERE
	LIT
	LIST
MONTAB:	ASCIZ	.JAN-.
	ASCIZ	.FEB-.
	ASCIZ	.MAR-.
	ASCIZ	.APR-.
	ASCIZ	.MAY-.
	ASCIZ	.JUN-.
	ASCIZ	.JUL-.
	ASCIZ	.AUG-.
	ASCIZ	.SEP-.
	ASCIZ	.OCT-.
	ASCIZ	.NOV-.
	ASCIZ	.DEC-.
EHGH:		;END LOC OF HIGH SEGMENT
	PAGE
	IFN	REENT<LOC 140>
	;LOW SEGMENT
SRCDEV:	BLOCK	1		;[2]SAVE DEV: OF SOURCE HERE
SRCPPN:	BLOCK	1		;[2]SAVE PPN OF SOURCE HERE
ZERLST:		;EVERYTHING BETWEEN HERE AND ELIST CLEARED
STACK:	BLOCK	STKSIZ		;PUSH DOWN STACK
MASBUF:	BLOCK	3		;BUFFER HEADER FOR MASTER FILE
NDXBUF:	BLOCK	3		;  "       "    "  INDEX FILE
STPBUF:	BLOCK	3		;  "       "    "  STOP FILE
MAFIL:	BLOCK	4		;PLACE TO STORE NAMES OF MASTER FILE
MASDEV:	BLOCK	1		;MASTER FILE DEVICE KEPT HERE
TMPST:	BLOCK	1		;THE ONE TIME LOCATION OF STOP LIST
STSTP:	BLOCK	1		;LOC OF START OF STOP LIST (AFTER SHUFFELING)
ENDSTP:	BLOCK	1		;LOC OF END OF STOP LIST (AFTER SHUFFEING)
SORTPT:	BLOCK	1		;LOC OF MASTER FILE FIRST WORD
EPROG1:	BLOCK	1		;CONTENTS OF JOBFF AT ENTRY TO PGM
CURLIN:	BLOCK	2		;CURRENT LINE BEING READ INTO CORE IN MASTER FILE
TITLE:	BLOCK	^D16		;LISTING TITLE KEPT HERE
OLDMAX:	BLOCK	SIZSTP		;UPPER LIMIT OF SORT STORED HERE
OLDMIN:	BLOCK	SIZSTP		;LOWER LINIT OF SORT STORED HERRE
MATBL:	BLOCK	MAXSAM		;TABLE OF MATCHES FOUND BY SORT
				;ROUTINE PASSED TO PRINT ROUTINE
				;FORMAT LH=START ADDR OF ENTRY,
				;RH=WINDOW OF ENTRY
OLDSIZ:	BLOCK	1		;SIZE OF STOP LIST
	IFN	FREQSW,
<
FRQLIN:	BLOCK	1
FRQPAG:	BLOCK	1
FRQBUF:	BLOCK	3
>
ELST:	BLOCK	1		;END OF ZERO OUT AREA
	END	START		;DAS IS ALLIS