Update to gobook@5e58e0a92b96bee61856a8ce6e75ed849bd504af

This commit is contained in:
Alan Donovan
2015-11-08 17:37:46 -05:00
parent 8eb326f5e8
commit 8908af67d0
7 changed files with 13 additions and 30 deletions
+6 -5
View File
@@ -1,8 +1,6 @@
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//+build ignore
package eval
import (
@@ -26,19 +24,19 @@ func write(buf *bytes.Buffer, e Expr) {
case Var:
fmt.Fprintf(buf, "%s", e)
case *unary:
case unary:
fmt.Fprintf(buf, "(%c", e.op)
write(buf, e.x)
buf.WriteByte(')')
case *binary:
case binary:
buf.WriteByte('(')
write(buf, e.x)
fmt.Fprintf(buf, " %c ", e.op)
write(buf, e.y)
buf.WriteByte(')')
case *call:
case call:
fmt.Fprintf(buf, "%s(", e.fn)
for i, arg := range e.args {
if i > 0 {
@@ -47,5 +45,8 @@ func write(buf *bytes.Buffer, e Expr) {
write(buf, arg)
}
buf.WriteByte(')')
default:
panic(fmt.Sprintf("unknown Expr: %T", e))
}
}