Path: utzoo!attcan!uunet!crdgw1!rpi!zaphod.mps.ohio-state.edu!mips!bridge2!jarthur!elroy.jpl.nasa.gov!zardoz.cpd.com!dhw68k!felix!asylvain From: asylvain@felix.UUCP (Alvin E. Sylvain) Newsgroups: comp.lang.c Subject: Re: C preprocessing Summary: Pre-processing for indentation - should be easy Keywords: C, indentation, preprocessing Message-ID: <151583@felix.UUCP> Date: 26 Sep 90 16:48:51 GMT References: <59770@iuvax.cs.indiana.edu> <18102@haddock.ima.isc.com> Sender: daemon@felix.UUCP Reply-To: asylvain@felix.UUCP (Alvin E. Sylvain) Organization: FileNet Corp., Costa Mesa, CA Lines: 43 In article <18102@haddock.ima.isc.com> karl@kelp.ima.isc.com (Karl Heuer) writes: >In article <59770@iuvax.cs.indiana.edu> bomgard@iuvax.cs.indiana.edu (Tim Bomgardner) writes: >>Wouldn't it be nice, if ... the compiler would do what I meant [by >>interpreting the indentation] instead of what I said? > >I personally like the idea, but it's not C (nor any other language I use, >though I understand Occam has it). So, being realistic, let's say instead: >Wouldn't it be nice if the compiler (or some related tool) would provide >(optional!) warnings for possibly misindented code? > >Things to worry about: (a) whitespace caused by macro expansion; (b) how to >count tabs vs. spaces; (c) accepting all plausible personal indentation styles >(or making it user-configurable). Just write a PRE-pre-processor. If the original C code is processed before the C pre-processor gets it, you'll truly have "what you mean", in terms of the actual code written, BEFORE any macro expansion. Tabs vs. spaces would have to be configured, similarly to your editor. Indentation styles would have to be standardized by the tool ... there is an infinite number of styles, and it would be difficult to try to implement more than 1 or 2. Since indentation is used for nearly all structured languages, the tool could produce different constructs for different languages, e.g., for *.c files, produce {} around indented code, for *.p (*.PAS) produce begin-end, etc. There may be some problem in deciding when to include semi-colons. This is definately creating a new 'language', much the same way the C pre-processor allows 'extensions' to C. If you REALLY want one, it should be a relatively trivial task to build using 'lex' and 'yacc'. It can have options for code-generation, or simple verification. Otherwise, just suffer along with the rest of us, and BE CAREFUL! (Note: I always use the '%' command in 'vi', which verifies the matching of () and {}. This should be standard practice for all programmers, along with other standard desk-checking procedures. Too bad you can't use '%' in Pascal.) -- ------------------------------------------------------------------------ "I got protection for my | Alvin "the Chipmunk" Sylvain affections, so swing your | Natch, nobody'd be *fool* enough to have bootie in my direction!" | *my* opinions, 'ceptin' *me*, of course!