void main(argc, argv)

- main program for document parser int argc; char *argv[];

The document parser is invoked as: `doc_parser [-cdeiklmst] [-r ] filename'. Only if the DEBUG option is on there may be debugging flags. The main program first checks the number of arguments. If the DEBUG option is not on, there must be at most two arguments, the filename and possibly the replacement file. The existence of a replacement file is indicated by the flag `-r' followed by the name of the file containing the replacements. If the DEBUG option is on, there may be four arguments, the debugflags, the replacement file and the filename. After this, the actions depend on whether DEBUG was defined when compiling the program. See introduction to the technical manual. If so, the debugflags are read, otherwise, no debugflags are allowed. Because debugflags are optional, the argument that contains the flags must start with `-'. All debugflags must be grouped together. For example, if the debugflags `c' and `d' are specified, the program is invoked as:

    doc_parser -cd ...
and not as:
    doc_parser -c -d ...
The only use of debugflags is to turn on debugging for various modules. The permissible debugflags are:
c	debug rep_pars.c
d	put debug information on stderr, instead of on file 'debug_info2'
e	debug entity.c, doc.g and extern.g
i	debug in.c
k	debug marked.g
l	debug lexical.c
m	debug myerror.c
s	debug shortref.c, shortnot.g
t	debug att_chk.c and rules.g
After reading the debugflags, the other arguments are read and checked. If there is a replacement file, checked is whether the file can be opened and contains a correct replacements. Also an filename can be given to be printed in error-messages. This is achieved by giving the flag `-z' followed by a string. The string is taken to be the filename to be used in error-messages. Next the input-file is opened for reading if opening the file is not allowed an error is printed and the program is halted. The main program then initializes all modules and the input-file is parsed. The 'complete' document is written on standard output if there is no replacement file. Otherwise the document according to the replacements is written on standard output. If the program is run in VAX/VMS, the 'complete' document is written in the file `doc_vol'.

doc_pars.c