using indentation rather than braces

KW Heuer kwh at bentley.UUCP
Tue May 20 02:09:45 AEST 1986


In article <968 at umd5.UUCP> umd5!zben (Ben Cranston) writes:
>Forgive me if this is too obvious to mention, but it seems to me that using
>the indentation information makes life much harder for programs like YACC
>and LEX that act by creating C source code.  Now they have to keep track of
>what column they are outputting to...

Slightly harder, but still not all that difficult.  Instead of outputting a
left brace, the program increments a variable; instead of a right brace, it
decrements.  Then each output line is preceded by that many blanks.

Of course, I'm assuming some support would be built into yacc and lex.  They
would automatically add the indentation level of your code blocks to that of
the automatically-generated blocks.

Btw, how would such a language interpret a one-liner like "if (c) a; b;"?
Would that be "if (c) {a;} b;" or "if (c) {a; b;}" or just illegal?

Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint



More information about the Comp.lang.c mailing list