Add Token.KeyFoo constants.

This commit is contained in:
Nigel Tao committed 2017-05-18 16:04:26 +10:00
1 parent 05a217e8a3
commit 90c5f4758e
8 files changed
+483 -358

No files matched your search

+3 -3
View File
@@ -104,19 +104,19 @@ func Render(w io.Writer, m *token.IDMap, src []token.Token, comments []string) (
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 != token.IDOpenParen || prevID.Flags()&flagsLIC == 0 {
if t.ID.Key() != token.KeyOpenParen || prevID.Flags()&flagsLIC == 0 {
buf = append(buf, ' ')
}
}
buf = append(buf, m.ByToken(t)...)
if t.ID == token.IDOpenCurly {
if t.ID.Key() == token.KeyOpenCurly {
if indent == maxIndent {
return errors.New("render: too many \"{\" tokens")
}
indent++
} else if t.ID == token.IDCloseCurly {
} else if t.ID.Key() == token.KeyCloseCurly {
if indent == 0 {
return errors.New("render: too many \"}\" tokens")
}