.TITLE VTLPAR - VTL Table Parser .IDENT /1.5/ .ENABL LC ;+ ; ; Free software BY ; Project Software & Development, Inc. ; ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided or ; otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by PROJECT SOFTWARE ; AND DEVELOPMENT, INC. ; ; PROJECT SOFTWARE assumes no responsibility for the use or reliability ; of this software on any equipment whatsoever. ; ; Project Software & Development, Inc. ; 14 Story St. ; Cambridge, Ma. 02138 ; 617-661-1444 ; ; ; Title: VTLPAR.MAC ; Author: Robin Miller ; Date: June 30, 1983 ; ; Description: ; ; Table parser for the VTL program. ; ;- .ENABL AMA .NLIST BEX ; .MCALL ISTAT$, STATE$, TRAN$ .MCALL ISTAT$, STATE$ ;+ ; ; Modification History: ; ; June 13, 1984 by Robin Miller. Version 1.5 ; Added keyword for "SHOW SECTION" command. ; ; June 8, 1984 by Robin Miller. Version 1.4 ; Added keyword for WRITE ALL to write the entire file. ; ; June 6, 1984 by Robin Miller. Edit (01), Version 1.3 ; Modify the CHKOPE routine to save all registers except R2. ; ; June 2, 1984 by Robin Miller. Version 1.2 ; Added keywords for SHOW MARGIN and SKIPS commands. ; ; May 24, 1984 by Robin Miller. Version 1.1 ; Put modified TRAN$ macro in this source file. ; ;- ;+ ; ; ; Description: ; ; VTL is a program used to list files on a VT100 family terminal. ; ; There are three methods of starting VTL; they are: ; ; 1. $ VTL ; VTL> ; ; This is the interactive mode. VTL continues to prompt for ; input until end of file (CTRL/Z) is encountered to exit. ; ; 2. $ VTL command_line ; ; VTL processes the specified command line and then exits. ; ; 3. $ VTL @command_file ; ; Using this method, command lines are read from the specified ; command file. The length of the command lines can be up to a ; maximum of 256 characters. The continuation character "-" is ; allowed at the end of a line. If the extension isn't specified ; the default is .CMD on RSX-11M or .COM on VAX/VMS. ; ; Command lines are of the form: ; ; input_file1,input_file2, ... input_filen/switches ; ;- ;+ ; ; The following patches from the MULTI-TASKER Volume 16, Number 3, allow ; unlimited keywords in TPARS. The artical was submitted by Ken Cross of ; Perceptics Corporation (thank-you Ken, this limitation was been a pain). ; ; >LBR TRANS.ORG=LB:[1,1]RSXMAC.SML/EX:TRAN$ ; >SLP @TRANS.COR ; ; TRANS.COR contents: ; ; TRANS.MAC=TRANS.ORG ; -29,37 ; .MACRO $$$TYP ; .BYTE 200 ; .ENDM $$$TYP ; $$$KEY = $$$KEY+1 ; $$$FLG = $$$FLG!1 ; .MACRO $$$EXT ; .WORD $$$TMP ; .ENDM ; / ; ; >LBR LB:[1,1]RSXMAC.SML=TRANS.MAC/RP ; ; The patch to TPARS changes five words using the ZAP utility: ; ; >LBR TPARS.OBJ=LB:[1,1]SYSLIB/EX:.TPARS ; >ZAP ; ZAP>TPARS.OBJ/AB ; Location Change To ; -------- ------ -- ; 2:202/ 042700 16500 ; 2:204/ 177700 1 ; 2:206/ 006300 240 ; 2:210/ 061600 240 ; 2:212/ 011000 240 ; 1:16/ 146400 146401 ; ; The last word changes the version from V0122 to V0122A. The revised ; module can then be replaced in SYSLIB if desried. ; ;- ; Modified version of TRAN$ macro. .MACRO TRAN$ TYPE,LABEL,ACTION,MASK,ADDR .PSECT $STATE MTRAN$ DBGTP$ .IF NB ACTION $$$FLG = $$$FLG!2 .MACRO $$$ACT .WORD ACTION .ENDM $$$ACT .ENDC .IF NB MASK $$$FLG = $$$FLG!30 .IF B ADDR .ERROR "MASK ADDRESS NOT PRESENT" .ENDC .MACRO $$$BIT .WORD MASK,ADDR .ENDM $$$BIT .ENDC .IF NB LABEL $$$FLG = $$$FLG!4 $$$STA = LABEL .ENDC .IRPC $$$$$X, .IF IDN <$$$$$X>,<"> .PSECT $KSTR $$$TMP = . .ASCII TYPE<377> .MACRO $$$TYP ;**NEW** .BYTE 200 ;**NEW** .ENDM $$$TYP ;**NEW** $$$KEY = $$$KEY+1 ;**NEW** $$$FLG = $$$FLG!1 ;**NEW** .MACRO $$$EXT ;**NEW** .WORD $$$TMP ;**NEW** .ENDM ;**NEW** .MEXIT ;**-9 .ENDC .IF IDN <$$$$$X>, $$$FLG = $$$FLG!1 .MACRO $$$EXT .WORD 0'TYPE .ENDM $$$EXT .MACRO $$$TYP .BYTE $SUBXP .ENDM $$$TYP .MEXIT .ENDC .MACRO $$$TYP .BYTE TYPE .ENDM $$$TYP .MEXIT .ENDM .PSECT .ENDM TRAN$ ; Define start of state and keyword tables. ISTAT$ STATE, KEYWRD ; Now define the actual state table. .GLOBL START, VTLCMD ; Skip any comment lines. STATE$ START TRAN$ <';>,$EXIT,,B.CMNT,STATUS TRAN$ <'!>,$EXIT,,B.CMNT,STATUS TRAN$ <'?>,$EXIT,HLPCMD,B.CMNT,STATUS TRAN$ $LAMDA ; Parse the input file name(s) and switches. STATE$ IFILE TRAN$ '/,ISW TRAN$ $ANY,IFILE,SIFILE,B.IFIL,STATUS TRAN$ $EOS,$EXIT ; Check for valid switches. STATE$ ISW TRAN$ !SWTBL,IFILE ;*************************************************************************** ; ; Subexpression to check for valid startup switches. ; STATE$ SWTBL ; Found the start of a switch. ; ; TRAN$ key_word,next_state,action_routine,bit,status_word TRAN$ !CHKNEG,SWSTA,SETNEG TRAN$ $LAMDA,,SETPOS STATE$ SWSTA TRAN$ !VTLSET,$EXIT TRAN$ !VTLCOM,$EXIT ; TRAN$ "BOTTOM" ; TRAN$ "FIND" TRAN$ "MARK",MRKSTA TRAN$ "OUTPUT",OFILE ; TRAN$ "PAGE" ; TRAN$ "RECORD" TRAN$ "VERSION",$EXIT,SHOVER,B.CMNT,STATUS ;****************************************************************************** ; Parse the mark buffer modulo count. STATE$ MRKSTA TRAN$ '= STATE$ TRAN$ $DNUMB,$EXIT,MRKCMD ;****************************************************************************** ; Parse the output file name and siwtches. STATE$ OFILE TRAN$ '= STATE$ TRAN$ $ANY,$EXIT,SOFILE,B.OFIL,STATUS ;****************************************************************************** ; ; Check for common startup option and listing commands. ; STATE$ VTLCOM TRAN$ "FEXIT",$EXIT,FECMD,B.DOPR,STATUS TRAN$ "FF",$EXIT,FFCMD,B.DOPR,STATUS TRAN$ "HELP",$EXIT,HLPCMD,B.CMNT!B.DOPR,STATUS TRAN$ "NARROW",$EXIT,NARCMD TRAN$ "RULER",$EXIT,RULCMD,B.DOPR,STATUS TRAN$ "SEEALL",$EXIT,SEECMD TRAN$ "WIDE",$EXIT,WIDCMD ; Check for common SET startup options and commands: STATE$ VTLSET TRAN$ "AVO",$EXIT,SETAVO TRAN$ "BINARY",$EXIT,SETBIN TRAN$ "HEADER",$EXIT,SETHDR,B.DOPR,STATUS TRAN$ "LINES",LINSTA TRAN$ "NARROW",$EXIT,NARCMD TRAN$ "NAME",$EXIT,SETNAM TRAN$ "NUMBERS",$EXIT,SETNUM TRAN$ "PROTECT",$EXIT,SETPRO,B.DOPR,STATUS TRAN$ "QUIET",$EXIT,SETQUI,B.DOPR,STATUS TRAN$ "RSX11",$EXIT,SETRSX,B.DOPR,STATUS TRAN$ "SCREEN",SCRSTA TRAN$ "SCROLL",$EXIT,SETSCB,B.DOPR,STATUS TRAN$ "SEEALL",$EXIT,SEECMD TRAN$ "SECTION",SECSTA TRAN$ "TECO",$EXIT,SETTEC TRAN$ "WIDE",$EXIT,WIDCMD TRAN$ "WAIT",$EXIT,SETWAI,B.DOPR,STATUS ;****************************************************************************** ; ; The next state is the entry point when listing a file. ; ; TRAN$ key_word,next_state,action_routine,bit,status_word STATE$ VTLCMD TRAN$ !CHKNEG,CMDSTA,SETNEG TRAN$ '+,CMDSTA,SETPLU TRAN$ $LAMDA,,SETPOS STATE$ CMDSTA TRAN$ $DNUMB,VTLNXT,NUMCMD ; Commands to be executed with first letter are put next: TRAN$ "FIND",FNDSTA TRAN$ "NEXT",$EXIT,,B.NEXT,STATUS TRAN$ "SET",SETSTA TRAN$ !VTLCOM,$EXIT TRAN$ "ADVANCE",VTLNXT,ADVCMD,B.DOPR,STATUS TRAN$ "BOTTOM",$EXIT,BOTCMD TRAN$ "BACKUP",VTLNXT,BCKCMD,B.DOPR,STATUS TRAN$ "CLOSE",$EXIT,WCLOSE,B.DOPR,STATUS TRAN$ "DELETE",$EXIT,DELCMD TRAN$ "EXIT",$EXIT,,B.EXIT,STATUS TRAN$ "FNDNXT",$EXIT,FNXCMD TRAN$ "LEFT",LEFTS TRAN$ "LINE",$EXIT,LINCMD TRAN$ "NDIR",$EXIT,NXDCMD,B.NEXT,STATUS TRAN$ "PAGE",$EXIT,PAGCMD TRAN$ "PRINT",$EXIT,PRICMD,B.DOPR,STATUS TRAN$ "RIGHT",RIGHTS TRAN$ "REFRESH",$EXIT,REFCMD TRAN$ "RESET",$EXIT,RESCMD TRAN$ "SECTION",$EXIT,SECCMD TRAN$ "SELECT",$EXIT,SELCMD TRAN$ "SHOW",SHOSTA,,B.DOPR,STATUS TRAN$ "SHL",RIGHTS TRAN$ "SHR",LEFTS TRAN$ "SPLIT",$EXIT,SPLCMD TRAN$ "SWAP",$EXIT,SWACMD,B.DOPR,STATUS TRAN$ "TOP",VTLNXT,TOPCMD TRAN$ "WRITE",WRTSTA,,B.DOPR,STATUS ;****************************************************************************** ; Check for negation of a command (either - or NO). STATE$ CHKNEG TRAN$ '-,$EXIT TRAN$ 'N STATE$ TRAN$ 'O,$EXIT ;****************************************************************************** ; Check for another command to parse. STATE$ VTLNXT TRAN$ $EOS,$EXIT TRAN$ $LAMDA,VTLCMD ;****************************************************************************** ; State for the FIND command (used to skip leading spaces/tabs). STATE$ FNDSTA TRAN$ $LAMDA,$EXIT,FNDCMD ;****************************************************************************** ; Parse the valid SET keywords. STATE$ SETSTA TRAN$ !CHKNEG,SETNXT,SETNEG TRAN$ $LAMDA,,SETPOS STATE$ SETNXT TRAN$ !VTLSET,$EXIT TRAN$ "SEARCH",SEASTA TRAN$ "TAB",TABSTA ; TRAN$ "TRUNCATE" ; TRAN$ "VERIFY" ; TRAN$ "WRAP" ; State for the "SET LINES n" or /LINES=n command. STATE$ LINSTA TRAN$ '=,LINNXT TRAN$ $LAMDA STATE$ LINNXT TRAN$ $DNUMB,$EXIT,SETLIN ; State for the "SET SCREEN n" or /SCREEN=n command. STATE$ SCRSTA TRAN$ '=,SCRNXT TRAN$ $LAMDA STATE$ SCRNXT TRAN$ $DNUMB,$EXIT,SETSCR ; State for the "SET SECTION n" or /SECTION=n command. STATE$ SECSTA TRAN$ '=,SECNXT TRAN$ $LAMDA STATE$ SECNXT TRAN$ $DNUMB,$EXIT,SETSEC,B.DOPR,STATUS ; State for the "SET SEARCH" command. STATE$ SEASTA TRAN$ "EXACT",$EXIT,SETEXA TRAN$ "GENERAL",$EXIT,SETGEN ; The "SET TAB" command must be followed by a number. STATE$ TABSTA TRAN$ $DNUMB,$EXIT,SETTAB ;****************************************************************************** ; Parse the valid SHOW keywords. STATE$ SHOSTA TRAN$ "FILE",$EXIT,SHOFIL TRAN$ "HEADER",$EXIT,SHOHDR TRAN$ "KEYPAD",$EXIT,SHOKEY TRAN$ "MARGIN",$EXIT,SHOMAR TRAN$ "MARK",$EXIT,SHOMRK .IFDF T$SKIP TRAN$ "SKIPS",$EXIT,SHOSKP .ENDC ; T$SKIP ; TRAN$ "SCREEN" TRAN$ "SEARCH",$EXIT,SHOSEA TRAN$ "SECTION",$EXIT,SHOSEC TRAN$ "VERSION",$EXIT,SHOVER ;****************************************************************************** ; Parse the valid WRITE keywords. STATE$ WRTSTA TRAN$ !CRANGE ; The next state calls the action routine to do the write. STATE$ TRAN$ $LAMDA,$EXIT,WRANGE ; Check for a valid range for writing. STATE$ CRANGE TRAN$ '.,RDELIM,WBEPAG TRAN$ $EOS,$EXIT,WPAGE TRAN$ $DNUMB,RDELIM,WBRANG TRAN$ "ALL",$EXIT,WWHOLE TRAN$ "BEGIN",RDELIM,WBEGIN TRAN$ "BPAGE",RDELIM,WBBPAG TRAN$ "EPAGE",RDELIM,WBEPAG TRAN$ "PAGE",$EXIT,WPAGE TRAN$ "SELECT",$EXIT,WSELCT TRAN$ "WHOLE",$EXIT,WWHOLE ; Check for the range delimiter. STATE$ RDELIM TRAN$ ':,ERANGE TRAN$ "THRU" ; Check for valid ending range. STATE$ ERANGE TRAN$ '.,$EXIT,WEEPAG TRAN$ $DNUMB,$EXIT,WERANG TRAN$ "BPAGE",$EXIT,WEBPAG TRAN$ "EPAGE",$EXIT,WEEPAG TRAN$ "END",$EXIT,WEND ;****************************************************************************** ; ; Move the margin left. ; ; Format: LEFT ! Moves left by default size. ; LEFT nn ! Moves left by specifed number. STATE$ LEFTS TRAN$ $DNUMB,VTLNXT,LEFCMD TRAN$ $EOS,$EXIT,LEFDEF ;****************************************************************************** ; ; Move the margin right. ; ; Format: RIGHT ! Moves right by default size. ; RIGHT nn ! Moves right by specifed number. STATE$ RIGHTS TRAN$ $DNUMB,VTLNXT,RIGCMD TRAN$ $EOS,$EXIT,RIGDEF ;****************************************************************************** ; The next STATE$ is needed for the end of the table. STATE$ ; Action routines for TPARS. ; Registers R0, R1, and R2 may be used by the action routines. ; All other registers must be preserved. ;****************************************************************************** ; Tell TPARS to ignore blanks during parse. ; This is used to ignore blanks in the options. IBLANK::CLRB .PFLAG ; Ignore blanks. RETURN ; Action routine to tell TPARS to pass blanks. ; This is used to pass blanks in the message. PBLANK::MOVB #1,.PFLAG ; Pass blanks. RETURN ;****************************************************************************** ; Action routines to set the negate flag true or false. SETNEG: MOV #-1,NEGFLG ; Show command is being negated. RETURN SETPLU: MOV #-1,PLUFLG ; Show a plus sign was specified. CLR NEGFLG ; Reset the negation flag. RETURN SETPOS: CLR NEGFLG ; Reset the negation flag CLR PLUFLG ; and the plus sign flag. RETURN ;****************************************************************************** ; Enable or disable force exit. FECMD: MOV #B.FE,R0 ; Set the FEXIT bit number. JMP DOSWM ; Turn the switch on or off. ;****************************************************************************** ; Enable or disable display of form feeds. FFCMD: MOV #B.FF,R0 ; Set the FORMFEED bit number. JMP DOSWM ; Turn the switch on or off. ;****************************************************************************** ; Change the mark buffer modulo count. MRKCMD: MOV IENTRY,R2 ; Copy the file entry address. MOV .PNUMB,R1 ; Copy the mark modulo count. BNE 10$ ; If NE, wo got one. INC R1 ; Force the modulo count to one. 10$: MOV R1,O.UMRK(R2) ; Save user specified modulo count. RETURN ;****************************************************************************** ; Enable or disable narrow screen display. NARCMD: MOV #B.NAR,R0 ; Set the NARROW bit number. CALL DOSWM ; Turn the bit on or off. ; /NARROW does a /WIDE and /-NARROW does a /WIDE. MOV #B.WIDE,R0 ; Set the WIDE bit number. COM NEGFLG ; Reverse the negate flag. CALL DOSWM ; Turn the bit on or off. CALL CHKOPE ; Is an input file open ? BCC 10$ ; If CC, no (presume startup option). JMP REFCMD ; Else, refresh the screen. 10$: RETURN ;****************************************************************************** ; Enable or disable display of data in see-all mode. SEECMD: MOV #S.SEE,R0 ; Set the SEEALL bit number. CALL DOSWT ; Turn the bit on or off. CALL CHKOPE ; Is an input file open ? BCC 10$ ; If CC, no (presume startup option). JMP REPAGE ; Get ready to redisplay the page. 10$: RETURN ;****************************************************************************** ; Enable or disable wide screen display. WIDCMD: MOV #B.WIDE,R0 ; Set the WIDE bit number. CALL DOSWM ; Turn the bit on or off. ; /WIDE does a /-NARROW and /-WIDE does a /NARROW. MOV #B.NAR,R0 ; Set the NARROW bit number. COM NEGFLG ; Reverse the negate flag. CALL DOSWM ; Turn the bit on or off. CALL CHKOPE ; Is an input file open ? BCC 10$ ; If CC, no (presume startup option). JMP REFCMD ; Else, refresh the screen. 10$: RETURN .SBTTL Copy the input or output file name(s) ;****************************************************************************** ; Save the input file name(s). SIFILE::MOV INPTR,R0 ; Copy address to store file names. CALL CPYFIL ; Now, copy the file specification. BCS FAIL ; If CS, the buffer was exceeded. MOV R0,INPTR ; Save the updated buffer address. RETURN ;****************************************************************************** ; Save the output file name. SOFILE::MOV OENTRY,R2 ; Copy the output file entry address. MOV O.FNAM(R2),R0 ; Copy address to store file name. CALL CPYFIL ; Now, copy the file specification. BCS FAIL ; If CS, the buffer was exceeded. RETURN ;****************************************************************************** ; Return failure to the table parser. FAIL:: ADD #2,(SP) ; Return failure to .TPARS. RETURN .SBTTL CHKOPE - Check for an open file. ;+ ; ; CHKOPE - Check for an open file. ; ; This routine is used to pass back a status as to whether an input file ; is open when executing a common command. If a file is not open, we ; presume we're parsing the switches on the command line, otherwise we ; presume we're currently listing a file. ; ; Inputs: ; None. ; ; Outputs: ; C bit clear/set = not open/file open. ; R2 = The file entry address. ; ; All other registers are preserved. ; ;- CHKOPE::MOV IENTRY,R2 ; Copy the file entry address. JSR R2,$SAVVR ; Save R0 - R2. (01) MOV O.FDB(R2),R0 ; Copy the FDB address. TST F.BDB(R0) ; Is an input file open ? BEQ 10$ ; If EQ, no (C bit clear). SEC ; Show the file is open. 10$: RETURN .SBTTL CPYFIL - Copy the file specification. ;+ ; ; CPYFIL - Copy the file specification. ; ; This routine is called by action routines to copy the file name strings ; from the input string being parsed. Syntax checking of the file name is ; done by the CSI routines called when opening a file. ; ; Inputs: ; R0 = The file name buffer address. ; R3 = The remaining input string byte count. ; R4 = The input string buffer address. ; ; Implicit inputs: ; .PCHAR = The character matched by the $ANY transition. ; ; Outputs: ; C bit clear/set = success/failure. ; ; R0 = The updated buffer address. ; R3 = The adjusted input string byte count. ; R4 = The updated input string buffer address. ; ;- CPYFIL::MOVB .PCHAR,(R0)+ ; Copy the first character. 10$: TST R3 ; Is there any count left ? BEQ 100$ ; If EQ, no (end of string). ; A slash, space, or horizontal tab stops the file copy. CMPB (R4),#'/ ; Encountering a switch ? BEQ 100$ ; If EQ, yes. CMPB (R4),#SPACE ; Encountering a delimiter ? BEQ 100$ ; If EQ, yes. CMPB (R4),#HT ; Encountering a delimiter ? BEQ 100$ ; If EQ, yes. TSTB (R0) ; Are we at end of the buffer ? BMI 90$ ; If MI, yes (file name too big). MOVB (R4)+,(R0)+ ; Else, copy the character. SOB R3,10$ ; Adjust the count and loop. BR 100$ ; Use common return ... 90$: SEC ; Show failure ... RETURN 100$: CLRB (R0) ; Terminate the file name. RETURN .SBTTL DOSWM - Change a switch mask status bit. ;+ ; ; DOSWM - Change a switch mask status bit. ; ; Inputs: ; R0 = The status bit number. ; ; Outputs: ; C bit clear/set = status bit set/cleared. ; ; All registers are preserved. ; ;- DOSWM:: BIS R0,SWMASK ; Presume we're setting switch. TST NEGFLG ; Are we setting the switch ? BEQ 10$ ; If EQ, yes. BIC R0,SWMASK ; Else, disable the switch. SEC ; Show status bit was cleared. 10$: RETURN .SBTTL DOSWS - Change a status bit. ;+ ; ; DOSWS - Change a status bit. ; ; Inputs: ; R0 = The status bit number. ; ; Outputs: ; C bit clear/set = status bit set/cleared. ; ; All registers are preserved. ; ;- DOSWS:: BIS R0,STATUS ; Presume we're setting switch. TST NEGFLG ; Are we setting the switch ? BEQ 10$ ; If EQ, yes. BIC R0,STATUS ; Else, disable the switch. SEC ; Show status bit was cleared. 10$: RETURN .SBTTL DOSWT - Change a table entry status bit. ;+ ; ; DOSWT - Change a table entry status bit. ; ; Inputs: ; R0 = The status bit number. ; ; Outputs: ; R2 = The file entry address. ; ; C bit clear/set = status bit set/cleared. ; ;- DOSWT:: MOV IENTRY,R2 ; Copy the file entry address. BIS R0,(R2) ; Presume we're setting switch. TST NEGFLG ; Are we setting the switch ? BEQ 10$ ; If EQ, yes (C bit is cleared). BIC R0,(R2) ; Else, disable the switch. SEC ; Show status bit was cleared. 10$: RETURN .END