Tweak puffsfmt'ing "iterate.8 (etc)".

This commit is contained in:
Nigel Tao committed 2017-10-21 14:33:29 +11:00
1 parent 1f9e391e7d
commit 8ee56a7911
2 files changed
+5 -4

No files matched your search

+4 -3
View File
@@ -108,14 +108,15 @@ func Render(w io.Writer, tm *token.Map, src []token.Token, comments []string) (e
prevID, prevIsTightRight := token.ID(0), false
for _, t := range lineTokens {
const (
flagsCIL = token.FlagsClose | token.FlagsIdent | token.FlagsLiteral
flagsCIS = token.FlagsClose | token.FlagsIdent | token.FlagsStrLiteral
flagsUB = token.FlagsUnaryOp | token.FlagsBinaryOp
flagsLIC = token.FlagsLiteral | token.FlagsIdent | token.FlagsClose
)
if prevID != 0 && !prevIsTightRight && !t.IsTightLeft() {
// The "(" token's tight-left-ness is context dependent. For
// "f(x)", the "(" is tight-left. For "a * (b + c)", it is not.
if t.ID.Key() != token.KeyOpenParen || prevID.Flags()&flagsLIC == 0 {
if t.ID.Key() != token.KeyOpenParen || prevID.Flags()&flagsCIS == 0 {
buf = append(buf, ' ')
}
}
@@ -140,7 +141,7 @@ func Render(w io.Writer, tm *token.Map, src []token.Token, comments []string) (e
if prevID != 0 && t.ID.Flags()&flagsUB == flagsUB {
// Token-based (not ast.Node-based) heuristic for whether the
// operator looks unary instead of binary.
prevIsTightRight = prevID.Flags()&flagsLIC == 0
prevIsTightRight = prevID.Flags()&flagsCIL == 0
}
prevID = t.ID
+1 -1
View File
@@ -72,7 +72,7 @@ pri func adler32.update(x[] u8)(checksum u32) {
in.x = in.x[:5552]
}
iterate.8(p ptr u8:in.x) {
iterate.8 (p ptr u8:in.x) {
s1 ~+= deref p as u32
s2 ~+= s1
}