Null source transformer for C
Joseph S. D. Yao
jsdy at hadron.UUCP
Thu Nov 13 14:40:56 AEST 1986
In article <1105 at cit-vax.Caltech.Edu> jon at cit-vax.UUCP (Jon Leech) writes:
>In article <5058 at brl-smoke.ARPA> jrv at MITRE-BEDFORD.ARPA (James R. Van Zandt) writes:
>>Several times I've wanted to make a change to some C source code that
>>would be minor, but requires parsing it. Some examples are:
> 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. ...
What I did at one point, after a round of 'style wars' had badly
trashed some otherwise good pieces of code, was to write into the
'compare' program some language-specific routines that recognised
general C and assembler constructs (assuming file.[csh] was right),
and transformed the files such that:
all white space became a single space (trailing WS stripped);
all '{'s and '}'s put on single lines, indented or not
semicolons not in strings or comments introduced new lines
no blank lines.
Terrible format to read, but a common, comparable format. It got
the job done, and was lots easier to write than a general parser.
Unfortunately, it's on an 800 bpi tape that I can't read right
now. But, you should be able to do this at home with some simple
equipment [;-)]. Just remember to match "" '' /**/.
--
Joe Yao hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}
jsdy at hadron.COM (not yet domainised)
More information about the Comp.lang.c
mailing list