mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 08:47:28 +01:00
Parse "f(i)".
This commit is contained in:
1 parent
b8e8cd627c
commit
8a7dee5a4d
4 files changed
+38
-23
No files matched your search
@@ -81,11 +81,16 @@ func RenderFile(w io.Writer, src []token.Token, m *token.IDMap) (err error) {
|
||||
|
||||
// Render the lineTokens.
|
||||
numOpens := len(opens)
|
||||
prevIsTightRight := true
|
||||
prevID := token.ID(0)
|
||||
for _, t := range lineTokens {
|
||||
if !t.IsTightLeft() && !prevIsTightRight {
|
||||
buf = append(buf, ' ')
|
||||
if prevID != 0 && !prevID.IsTightRight() && !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.IsBinaryOp() {
|
||||
buf = append(buf, ' ')
|
||||
}
|
||||
}
|
||||
|
||||
buf = append(buf, m.ByKey(t.Key())...)
|
||||
|
||||
if t.IsOpen() {
|
||||
@@ -100,7 +105,7 @@ func RenderFile(w io.Writer, src []token.Token, m *token.IDMap) (err error) {
|
||||
opens = opens[:len(opens)-1]
|
||||
}
|
||||
|
||||
prevIsTightRight = t.IsTightRight()
|
||||
prevID = t.ID
|
||||
}
|
||||
if numOpens != len(opens) {
|
||||
indent++
|
||||
|
||||
Reference in new issue
Block a user