Since there is no good reason to *allow* improper indentation why not
*mandate* it then?  (I'm personally glad my transmission doesn't let me
put the car in reverse gear while on the freeway at 65mph but that's me.)



Sure there is. It's only for humans. And humans can just write a script to
do indentation or whatever using the simplest data structure known to man, a
stack (lexing will suffice, no parsing to solve this needed folks), for
whatever elements the trace, and do some indentation. You can make a simple
script in any language, though I'd use PERL and do whatever makes you happy.

#/usr/bin/perl

my %occs = ();
my $parencount = 0;
while(<>)
{
       chomp;
       while(/([()])/g)
       {
               if ( $1 eq "(" )
               {
                       $parencount++;
               }
               elsif ( $1 eq ")" )
               {
                       $parencount--;
               }
               if ($parencount < 0)
               {
                       print "One to many closing parenthesis at <$_>\n";
               }
       }
}
if ($parencount > 0)
{
       print "One to many opening parens by end of file..... \n";
}

Which could easily be changed to match arbitrary characters and print tabs
instead of counting..........

As for the car analogy, I see a lot more sense in not mandating whitespace
behavior, which was deprecated long ago in favor of facilitating people to
make there own tools as they please.

-T

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to