From gang!wuphys!busch!we53!mgnetp!ihnp4!zehntel!hplabs!tektronix!orca!hammer!bradn Tue Jul 17 12:29:33 1984
Relay-Version: version B 2.10.2 7/1/84; site plus5.UUCP
Posting-Version: version B 2.10.1 (Tek) 9/26/83; site hammer.UUCP
Path: plus5!gang!wuphys!busch!we53!mgnetp!ihnp4!zehntel!hplabs!tektronix!orca!hammer!bradn
From: bradn@hammer.UUCP (Brad Needham)
Newsgroups: net.sources
Subject: Cparen - C expression parenthesizer, Version 2
Message-ID: <816@hammer.UUCP>
Date: 17 Jul 84 17:29:33 GMT
Date-Received: 20 Jul 84 00:51:14 GMT
Organization: Tektronix, Wilsonville OR
Lines: 1000

Here is the latest version of the C expression parenthesizer, cparen.
It's been improved in several ways since I last sent it out to the net:
	- The copyright notice has been rewritten so that you can
	  *legally* copy & use cparen.
	- The shar file has been modified to work around a mail bug
	  that likes to eat pairs of backslashes.
	- This version will run under V7, Sys III, Sys V, and all BSD's.
	- This version now parses string and character constants that
	  contain quoted newlines.

Since so many people complained about not being able to pump a whole program
through cparen, I've included my epistle on parentheses & cparen.

Portability is necessarily a community effort.
Many thanks go to all the people who shared cparen's successes & failures
with me.

Brad Needham
Tektronix, Inc.
...decvax!tektronix!tekecs!bradn

======= The Epistle on Parentheses & Cparen ==============================
Ways in which I use cparen:
1) from vi.
	I first copy the source line(s) that contains a confusing
	expression, via ":.t."; I then filter the copy through cparen,
	via "!!cparen".  Once I have examined the parenthesized copy,
	it remove it, via "dd".
2) interactively.
	I invoke cparen from the shell, via "cparen".
	I type a confusing expression, e.g.
		--a->x[5]
	I then type ^D and look at the output.

The main reason that Cparen doesn't process whole files is that I
didn't want to go to the trouble of creating a grammar (that's the
parse.y file) that would parse the whole C language -- C declarations,
for example, can be very complex.  I wrote Cparen to be able to read C
source while I was editing it -- I see no reason to make Cparen an
order of magnitude more complex just so I can get a listing of a
program with all the expressions fully parenthesized.

Another reason for not processing whole files is my philosophy of use
of parentheses.  A fully-parenthesized expression is often less
readable than a minimally-parenthesized one.  My rule of parentheses
when writing code is this: use parentheses only to change the
evaluation of the expression or to make the code more readable --
extraneous parentheses confuse the reader.  In keeping with that
philosophy, I use Cparen to answer questions I have when reading code.
======== End of the Epistle ==============================================
