.TITLE MISPAR - MISH Table Parser .IDENT /1.0/ .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: MISPAR.MAC ; Author: Robin Miller ; Date: November 11, 1982 ; ; Description: ; ; Table parser for MISH program. ; ; ; Modification History: ; ;- .ENABL AMA .NLIST BEX .MCALL ISTAT$, STATE$, TRAN$ ;+ ; ; ; Description: ; ; MISH is a program used to convert 512 byte record input files into ; eighty byte ascii text files for transmission with VAXnet, RSXnet, and ; HASP Central. ; ; ; There are three methods of starting MISH; they are: ; ; 1. $ MISH ; MISH> ; ; This is the interactive mode. MISH continues to prompt for ; input until end of file (CTRL/Z) is encountered to exit. ; ; 2. $ MISH command_line ; ; MISH processes the specified command line and then exits. ; ; 3. $ MISH @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_file/switches output_file/switches ; ; Where the switches are: ; ; /ANALYZE ; ; Used to analyze the contents of a file which was compressed. The output ; is a formatted dump of the header record and each compressed record. ; ; /DATA ; ; Used when analyzing to get a formatted dump of the data in each record. ; ; /HEADER ; ; Used when analyzing a compressed file to get a formatted dump of the ; header record. This is the default mode. ; ; /HEXADECIMAL ; ; Used when analyzing a file to output the string control bytes of the ; compressed records in hexadecimal. This is the default mode. ; ; /OCTAL ; Used when analyzing a file to output the string control bytes of the ; compressed records in octal. ; ; /REVERSE ; Used when analyzing a file to output the string control bytes of the ; compressed records in reverse video on a VT100 terminal. ; ; /COMPRESS ; ; Used to compress files into eighty byte records for transmission on the ; HASP punch stream. This is the default mode. ; ; /DECOMPRESS ; ; Used to decompress files into their original file format. ; ; /HELP ; ; Used to output a short description of the command format and switches. ; Help is also output when the first character of a command line starts ; with a question mark ("?"). ; ; /TOTALS ; ; Used to output the total number of blocks and records compressed or ; decompressed. This is the default mode. This switch may be negated ; to suppress the totals report. ; ; Examples: ; ; $ MISH ROBINQ.QWK ROBINQ.MSH ; ; This command compresses the input file named ROBINQ.QWK into ; a compressed output file named ROBINQ.MSH. ; ; $ MISH ROBINQ.MSH/DECOMPRESS ; ; This command decompresses the input file named ROBINQ.MSH into its ; original file format. Since an output file name wasn't specified, ; the original file name is used. Using the above example, the output ; file would be named ROBINQ.QWK. ; ; $ MISH ROBINQ.MSH/ANALYZE ; ; This command outputs a formatted header record from the input file ; named ROBINQ.MSH. Since an output file wasn't specified, the output ; is written to the terminal by default. ; ;- ; Define start of state and keyword tables. ISTAT$ STATE, KEYWRD ; Now define the actual state table. .GLOBL START ; Skip any comment lines. STATE$ START TRAN$ <';>,$EXIT,,B.CMNT,STATUS TRAN$ <'!>,$EXIT,,B.CMNT,STATUS TRAN$ <'?>,$EXIT,HELP,B.CMNT,STATUS TRAN$ $LAMDA ; Give the user the option of starting off with a switch. STATE$ SW1 TRAN$ '/,SW2 TRAN$ $LAMDA,SKIP1 ; Found the start of a switch. STATE$ SW2 TRAN$ !SWTBL,SW1 ; Skip any spaces/tabs preceding the input file name. STATE$ SKIP1 TRAN$ $BLANK,ILOOP TRAN$ $LAMDA ; Next should be the input file name. STATE$ ILOOP TRAN$ $BLANK,ISW1 TRAN$ '/,ISW2 TRAN$ $ANY,ILOOP,SIFILE,B.IFIL,STATUS TRAN$ $EOS,$EXIT ; Check for switches following the input file name. STATE$ ISW1 TRAN$ '/,ISW2 TRAN$ $LAMDA,ISW3 STATE$ ISW2 TRAN$ !SWTBL,ISW1 STATE$ ISW3 TRAN$ $BLANK,OLOOP TRAN$ $LAMDA ; Next should be the output file name. STATE$ OLOOP TRAN$ $BLANK,OSW1 TRAN$ '/,OSW2 TRAN$ $ANY,OLOOP,SOFILE,B.OFIL,STATUS TRAN$ $EOS,$EXIT ; Check for switches following the output file name. STATE$ OSW1 TRAN$ '/,OSW2 TRAN$ $LAMDA,OSW3 STATE$ OSW2 TRAN$ !SWTBL,OSW1 STATE$ OSW3 TRAN$ $BLANK,FIN1 TRAN$ $LAMDA ; Next should be the end of the input string. STATE$ FIN1 TRAN$ $EOS,$EXIT ;*************************************************************************** ; ; Subexpression to check for valid switches. ; ; Check for switches following the output file name. STATE$ SWTBL ; Found the start of a switch. ; ; TRAN$ key_word,next_state,action_routine,bit,status_word TRAN$ !NEGSW,$EXIT TRAN$ "ANALYZE",$EXIT,ANACT TRAN$ "COMPRESS",$EXIT,COACT TRAN$ "DECOMPRESS",$EXIT,DEACT TRAN$ "DATA",$EXIT,,B.DATA,STATUS TRAN$ "HELP",$EXIT,HELP,B.CMNT,STATUS TRAN$ "HEADER",$EXIT,,B.HDR,STATUS TRAN$ "HEXADECIMAL",$EXIT,NOOCT,B.HEX!B.DATA,STATUS TRAN$ "OCTAL",$EXIT,NOHEX,B.OCT!B.DATA,STATUS TRAN$ "REVERSE",$EXIT,,B.REV!B.DATA,STATUS TRAN$ "TOTALS",$EXIT,,B.TOT,STATUS ; Sub-expression to check for negating of switches. STATE$ NEGSW TRAN$ '- STATE$ TRAN$ "TOTALS",$EXIT,NOTOT TRAN$ "HEADER",$EXIT,NOHDR ; 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. ;*************************************************************************** ; Action routines to setup the type of operation. ANACT: MOV #-2,TYPOPR ; Setup for analayzing the file. RETURN COACT: CLR TYPOPR ; Setup for compressing the file. RETURN DEACT: MOV #2,TYPOPR ; Setup for decompressing the file. RETURN ;*************************************************************************** ; Action routines to negate a status bit. NOHDR: BIC #B.HDR,STATUS ; Don't output the header record. RETURN NOHEX: BIC #B.HEX,STATUS ; Disable hexadecimal mode. MOV #4,FIELDW ; Field width for octal output. RETURN NOOCT: BIC #B.OCT,STATUS ; Disable octal mode. MOV #3,FIELDW ; Field width for hexadecimal. RETURN NOTOT: BIC #B.TOT,STATUS ; Don't output the totals. RETURN ;*************************************************************************** ; Save character for input file name. SIFILE::TSTB @INPTR ; ARE WE AT END OF THE BUFFER ? BMI FAIL ; IF MI, YES MOVB .PCHAR,@INPTR ; NO, SAVE CHARACTER FOR FILE NAME INC INPTR ; AND POINT TO THE NEXT LOCATION CLRB @INPTR ; ENSURE FILE NAME HAS TERMINATOR RETURN ;*************************************************************************** ; Save character for output file name. SOFILE::TSTB @OUTPTR ; ARE WE AT END OF THE BUFFER ? BMI FAIL ; IF MI, YES MOVB .PCHAR,@OUTPTR ; NO, SAVE CHARACTER FOR FILE NAME INC OUTPTR ; AND POINT TO THE NEXT LOCATION CLRB @OUTPTR ; ENSURE FILE NAME HAS TERMINATOR RETURN ; Return failure to the table parser. FAIL: ADD #2,(SP) ; RETURN FAILURE TO .TPARS RETURN .END