.TITLE REFPAR - REFormat Table Parser .IDENT /1.1/ .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: REFPAR.MAC ; Author: Robin Miller ; Date: December 13, 1982 ; ; Description: ; ; Table parser for the REFormat program. ; ; Modification History: ; ;- .ENABL AMA .NLIST BEX .MCALL ISTAT$, STATE$, TRAN$ ;+ ; ; Description: ; ; REFormat is a program used to convert input files into variable length ; output files with implied carriage control. It writes separate records ; for each carriage return/line feed combination, strips nulls, converts ; line printer Vertical Format Control, and removes the delete sequence ; (backspace-space-backspace) which occurs in RSXNET/VAXNET logfiles. ; ; There are three methods of starting REFORMAT; they are: ; ; 1. $ REF ; REF> ; ; This is the interactive mode. REF continues to prompt for ; input until end of file (CTRL/Z) is encountered to exit. ; ; 2. $ REF command_line ; ; REF processes the specified command line and then exits. ; ; 3. $ REF @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: ; ; /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: ; ; $ REF RSXNET.LOG * ; ;- ; 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$ '*,OSW1,,B.WILD,STATUS 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$ "ASCII",$EXIT,CHKEBC,B.ASC,STATUS TRAN$ "BACKSPACE",$EXIT,,B.BACK,STATUS TRAN$ "EBCDIC",$EXIT,CHKASC,B.EBC,STATUS TRAN$ "ESCAPE",$EXIT,,B.ESC,STATUS TRAN$ "HELP",$EXIT,HELP,B.CMNT,STATUS TRAN$ "NAME",$EXIT,,B.NAME,STATUS TRAN$ "NONAME",$EXIT,NONAME TRAN$ "NOBACKSPACE",$EXIT,NOBACK TRAN$ "NOESCAPE",$EXIT,NOESC TRAN$ "TOTALS",$EXIT,,B.TOT,STATUS TRAN$ "VFU",$EXIT,,B.VFU,STATUS ; Sub-expression to check for negating of switches. STATE$ NEGSW TRAN$ '- STATE$ TRAN$ "BACKSPACE",$EXIT,NOBACK TRAN$ "ESCAPE",$EXIT,NOESC TRAN$ "NAME",$EXIT,NONAME TRAN$ "TOTALS",$EXIT,NOTOT TRAN$ $EOS,$EXIT ; 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. ;*************************************************************************** CHKEBC: BIT #B.EBC,STATUS ; Translate both ascii and ebcdic ? BNE FAIL ; If NE, they tried RETURN CHKASC: BIT #B.ASC,STATUS ; Translate both ascii and ebcdic ? BNE FAIL ; If NE, they tried RETURN NOBACK: BIC #B.BACK,STATUS ; Don't remove backspaces RETURN NOTOT: BIC #B.TOT,STATUS ; Don't output the totals. RETURN NONAME: BIC #B.NAME,STATUS ; Don't output the file name RETURN NOESC: BIC #B.ESC,STATUS ; Don't break output records on Esc RETURN ; sequences. ;*************************************************************************** ; 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