PrettyPrinting and Comments
Les Tyrrell
tyrrell at canis.uiuc.edu
Tue Apr 11 02:34:30 UTC 2000
Dan Ingalls wrote:
>
> Folks -
>
> As many of you know, the prettyPrinter does not do a great job of placing comments. Has anyone out there improved this situation, preferably without too many other changes? Pointers to any related work appreciated.
>
> Thanks
> - Dan
The comments are misplaced because there is an overly early optimisation that takes
place during parsing. This is repairable ( to some extent ) by removing that optimisation.
That optimisation properly belongs in the code generation phase, not during the parse
tree construction phase.
There are other issues, which to some extent can be inferred- comments placed at the
end of a line but prior to a line ending ought to be marked by the parser in a special
way, also it would be good if the parser were able to apply some heuristics about
making a better guess about whether the first comment in a method belongs to the
first statement of that method, or to the method. There are a few gray areas like
that, but decent heuristics could probably be devised to do well in most cases.
- les
More information about the Squeak-dev
mailing list
|