Remove all the comments.
Add a diagnostic printout at the beginning of each function.
Compile a list of variables and the functions they're defined in.
For all variables declared to be a particular type (say, COMPLEX),
replace the operators + - * / with equivalent function calls.
Any of these would leave most of the source code unchanged. It seems
to me that the easiest way to implement one would be to start with LEX
and YACC code for a source to source transformer that would make no
changes. That is, action routines that would only build a parse tree,
then tree walking routines that would (approximately) reproduce the
original source code. Does anyone know a public domain source for
(1) LEX/YACC code for such a null transformer,
(2) any LEX/YACC code for parsing C, or
(3) LEX code for C?
Please mail directly to me, as I don't subscribe to all of these groups.
- Jim Van Zandt
> replace the operators + - * / with equivalent function calls.
Another example that I badly needed recently is a 'diff'-like program
driven by syntax rather than text; I had two divergent versions of a large
program with differing indentations, preprocessor usage, etc. The idea is
to build parse trees for two sets of source code and compare them function
by function at the syntax level, then reconstruct source code for the
-- Jon Leech (j...@csvax.caltech.edu || ...seismo!cit-vax!jon)
Caltech Computer Science Graphics Group
__@/