Re: Compiler indentation
David Hakim <dhakim-Gkm/TONP9n1Wk0Htik3J/[email protected]> Sat, 25 Jan 2003 18:06:23 -0500
| Newsgroups | gmane.comp.lang.moto.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tuesday, January 21, 2003, at 11:18 AM, Stefano Corsi wrote: > Hi Dave, > > I open another lead, regarding emitting compiler code. I have noticed > that sometimes the indentation of resulting C code does not match the > scope, maybe because no OutputIndent() function gets called or maybe > because a tab becomes a space somewhere and this result in different > indentation at the end. > I feel that indentation can help both programmers and users to > discover if something goes wrong with the compiler (I experienced this > when I was debugging the for inline declaration), so I think that > sooner or later we should address this problem. > I have this proposal that centralizes any space/tab emitting code. > Another advantage is that you can decide at any moment to change the > indentation character (maybe it could become an option). I very much like your INDENT macro idea and how easily the indentation character can be changed you should definitely commit this part. > I've attached a -p0 patch. I have just modified motoc_for as en > example and I have added two or three functions. > > The idea is to deliberately push and pop indent levels without using > the stack frame counter. This I'm not sure of. As you saw when implementing inline declarations, when the scopes for interpreted vs compiled code differ its often a sign that we're doing something we shouldn't be :) . By attaching indentation levels to scopes we enforce this idea visually. Perhaps we should be pushing new scopes onto the stack where indentation doesn't match scope depth currently. Where is this happening now ? -Dave > What do you think? > > Stefano > > > > > <indent.patch>