]> Cypherpunks repositories - gostls13.git/commit
Intersperse comments nicely when printing an AST.
authorRobert Griesemer <gri@golang.org>
Tue, 28 Jul 2009 23:38:59 +0000 (16:38 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 28 Jul 2009 23:38:59 +0000 (16:38 -0700)
commit2210a643b7a914cd0dc6f251544d93e030f0def6
tree2bb456a113d2316478ccfcce4f8e7bb3e42763d3
parentf62585118cade28409bf7c217260844cc054954f
Intersperse comments nicely when printing an AST.
gofmt formatted source code looks pretty good already;
with a bit more fine-tuning it should be great.

printer.go:
- Implemented comment intersperse algorithm.
  The approach is a result of many trial-and-error
  experiments but at this point reasonably simple
  and open to arbitrary fine-tuning.

parser.go:
- Simplified handling of lead and line comments
  (formerly called leading and trailing comments).
- Use a comments list instead of an array (I may
  change this back - this is not obviously better
  and uses more space).

doc.go:
- Remove comments from AST nodes that have been
  'consumed' in the documentation to avoid duplicate
  printing of them. Allows for better control of
  what is printed w/o use of printing control flags
  (which are hard to use and not fine-grained enough).

Corresponding adjustments to various clients of these
files.

R=rsc
DELTA=478  (275 added, 108 deleted, 95 changed)
OCL=32185
CL=32380
12 files changed:
src/cmd/godoc/godoc.go
src/cmd/gofmt/gofmt.go
src/cmd/gofmt/test.sh
src/pkg/go/ast/ast.go
src/pkg/go/ast/filter.go
src/pkg/go/doc/doc.go
src/pkg/go/parser/parser.go
src/pkg/go/printer/printer.go
src/pkg/go/printer/printer_test.go
src/pkg/go/printer/testdata/golden1.go
src/pkg/go/printer/testdata/golden1.x
src/pkg/go/printer/testdata/source1.go