}
-
// writeCommentSuffix writes a line break after a comment if indicated
// and processes any leftover indentation information. If a line break
// is needed, the kind of break (newline vs formfeed) depends on the
}
-
// intersperseComments consumes all comments that appear before the next token
// and prints it together with the buffered whitespace (i.e., the whitespace
// that needs to be written before the next token). A heuristic is used to mix
}
case *ast.BasicLit:
+ // TODO(gri): string contents must remain unchanged through tabwriter!
p.print(x.Value);
case *ast.StringList:
// Trimmer
// A trimmer is an io.Writer filter for stripping trailing blanks
-// and tabs, and for converting formfeed characters into newlines.
+// and tabs, and for converting formfeed and vtab characters into
+// newlines and htabs (in case no tabwriter is used).
//
type trimmer struct {
output io.Writer;
}
+// Design note: It is tempting to eliminate extra blanks occuring in
+// whitespace in this function as it could simplify some
+// of the blanks logic in the node printing functions.
+// However, this would mess up any formatting done by
+// the tabwriter.
+
func (p *trimmer) Write(data []byte) (n int, err os.Error) {
// m < 0: no unwritten data except for whitespace
// m >= 0: data[m:n] unwritten and no whitespace
m = n;
}
+ case '\v':
+ b = '\t'; // convert to htab
+ fallthrough;
+
case '\t', ' ':
// write any pending (non-whitespace) data
if m >= 0 {