Category : C Source Code
Archive   : CPAREN.ZIP
Filename : README.1ST
==========
This was originally intended for BSD UNIX(tm), and by use of the
-Dindex=strchr, etc made compilable on USG (Sys V) and now fixed to
compile under MSDOS. This readme gives the main purpose of the util,
very briefly (read info and cparen.doc for details), what is needed to
build this under MSDOS, and what appears to be an annoying MSC bug.
The program is NOT intended to process whole C files, so don't even
try. This would require the program being able to parse the whole C
language. It is intended to have an expression one wants to check
piped thru it from an editor, or, one can start the program, type in
the expression standing alone, and end with (for MSDOS, a ^Z) EOF.
Cparen will output the expression with parentheses added showing how
it is evaluated. The purpose is to aid those that cannot remember all
the subleties of the precedence and associativity of C operators,
etc., and thus reduce the adding of parentheses in the actual code to
ensure that it is evaluated as one wants. Too many parentheses
clutter things up, and make the code even HARDER to read.
Since the YACC and LEX utils from UNIX(tm) are used to build the
parser and lexical analyzer, one cannot directly port the program to
MSDOS, and include the generated parse.c and lex.c files as that
output of yacc and lex are covered by copyright. However, the
Freeware utils BISON and FLEX, which are functionally the same, are
available for MSDOS, and while there are some differences, in most
cases these can be used in place of the AT&T utils. Flex has an
additional advantage for many cases in that a lex library is not
required, all references are either defined in the output as macros,
or as functions. In the case of CPAREN, there were no
incompatabilities.
In building for DOS though, I ran across a "feature" of MSC 5.1 that
resulted in failure of the output of bison (run as yacc) to compile.
The resultant file, renamed to parse.c, has a construct that goes:
#ifndef YYSTYPE
#define YYSTYPE int;
#endif
which didn't recognize YYSTYPE as being previously defined, and made
YYSTYPE be defined as int. Earlier, in an include, YYSTYPE was
typedef'd as a union. Apparently, #ifndef / #ifdef considers a
typedef'd identifier as not being defined, and overrides it. Fix was
to edit and use a %define in parse.y, and remove the typedef from the
header (cparen.h). Using the " %union YYSTYPE {... " in the parse.y
file causes bison to make the typedef, and being aware of it, doesn't
place the #ifndef YYSTYPE lines in the resultant parse.c file. Also,
this makes it appear in y_tab.h so the YYSTYPE is defined for other
files that include the header.
Anyway, after all this, the thing works, so enjoy. For those without
FLEX or BISON (PD YACC), I included the PARSE.C, Y_TAB.H, and LEX.C
files generated in the archive.
pat@rwing Mon Oct 16 11:40:55 PDT 1989
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/