Table of contents


NAME

chkdelim - check delimiter balance

SYNOPSIS

chkdelim [ -? ] [ -author ] [ -copyright ] [ -help ] [ -ignore delimiters ] [ -noparagraph ] [ -noTeX ] [ -paragraph ] [ -TeX ] [ -version ] [ < infile or file1 file2 file3 ... ] > outfile

DESCRIPTION

chkdelim filters a list of files, or its standard input if no filenames are provided, matching group delimiters: angle brackets, curly braces, parentheses, square brackets, forward quotes (apostrophes or acutes), backward quotes (graves), quotation marks, and dollar signs (used in the TeX typesetting system).

Warning messages are printed to stdout whenever unbalanced delimiters are found, giving the delimiter and its line, column, and file positions. The output format is recognizable by the GNU emacs M-x compile command, making it easy to parse the error messages and jump to the error locations with the keystrokes C-x `(next-error).

Dollar signs are checked only when the -TeX option has been specified. Single dollar signs are expected to occur in pairs on the same line for in-line math mode. Doubled adjacent dollar signs may be separated by several lines for display-math mode. However, if more than 10 lines, or a blank line, separate doubled dollar signs, a warning is issued.

A backslash preceding a delimiter prevents it from being recognized as a delimiter; this is a suitable choice for TeX documents, as well as for C-like programming languages and UNIX shells.

A backslash-asterisk pair preceding an open parenthesis also prevents recognition of the parenthesis. This is suitable for nroff and troff two-letter user-defined macros, such as \*(Te. Such a character sequence is highly unlikely in other files.

Checking of forward quotes (apostrophes) may be less useful, because they are used both as string delimiter characters in computer programming languages, and in typewritten text, and also singly, marking possessives or elided characters in English-language text. The -TeX option described below implements a partial workaround for this ambiguity.

If unbalanced delimiters are needed, it is often possible to insert a matching delimiter in a nearby comment so that the delimiter appears to chkdelim to be properly balanced. This will reduce the number of messages issued, so that the real errors will be more evident.

chkdelim is a handy tool for detecting common errors in electronic documents and computer programs. Its other purpose is to demonstrate a modest lex(1) program.


OPTIONS

Command-line switches may be abbreviated to a unique leading prefix, and letter case is not significant. Options affect only the processing of files that follow them on the command line. Should a file name begin with a hyphen, you must protect it with a directory path (e.g. ./) to prevent it from being interpreted as a command-line option.
-?
Display a brief help message on stderr, and terminate. Same as -help.
-author
Display author information on stderr, and then continue processing.
-copyright
Display copyright information on stderr, and then continue processing.
-help
Display a brief help message on stderr, and terminate. Same as -?.
-ignore delimiters
Forget the settings of any previous -ignore option, and then specify one or more delimiter characters that are to be ignored. In the case of paired delimiters (braces, brackets, parentheses), either, or both, of a pair may be specified.

Since most delimiter characters have special significance to command shells, it will usually be necessary to protect them suitably from shell interpretation, such as with backslashes, or inside quoted strings.

Angle brackets are more commonly used for less-than and greater-than symbols, rather than <paired>, so -ignore \<\> will be a likely chkdelim option on UNIX systems.

-noparagraph
Suppress any -paragraph option specified earlier on the command line.
-noTeX
Suppress any -TeX option specified earlier on the command line.
-paragraph
At end of paragraph, which is a line that is empty, or contains only whitespace, issue any needed error messages, and then forget any delimiter imbalances. This option is often useful to limit the number of error messages that can appear.
-TeX
Check dollar signs in TeX files. Without this option, such characters are always ignored.

Also, check that forward and backward quotes appear in open/close pairs: `...' and ``...'', instead of in the forms `...` and '...' used in computer programming languages.

Forward quotes between letters or digits are ignored, so that possessives and elisions do not raise bogus warnings.

-version
Display version information on stderr, and then continue processing.

BUGS

chkdelim cannot detected improper nesting of delimiters, such as in the string ( ... [ ... ) ].

In TeX documents, quotation marks "..." should be used only inside verbatim environments, but chkdelim cannot recognize such environments, so it will only warn if quotation marks are unbalanced. LaTeX users are advised to employ the lacheck(1) utility to detect incorrect use of quotation marks.


SEE ALSO

awk(1), lacheck(1), lex(1).

AUTHOR

Nelson H. F. Beebe, Ph.D.
Center for Scientific Computing
Department of Mathematics
University of Utah
Salt Lake City, UT 84112
USA
Tel: +1 801 581 5254
FAX: +1 801 581 4148
Email: beebe@math.utah.edu
WWW URL: http://www.math.utah.edu/~beebe