cmd/goyacc: print newlines more consistently
Change-Id: I7ba77f0f28374b1ef2a5d08c0c273ad2fb5523c8
GitHub-Last-Rev: dfbff0bf0acaa333a72fadca81eb4b75e9f3716e
GitHub-Pull-Request: golang/tools#240
Reviewed-on: https://go-review.googlesource.com/c/tools/+/241040
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/cmd/goyacc/yacc.go b/cmd/goyacc/yacc.go
index a637386..fdd44c1 100644
--- a/cmd/goyacc/yacc.go
+++ b/cmd/goyacc/yacc.go
@@ -712,7 +712,8 @@
// put out names of states.
// commented out to avoid a huge table just for debugging.
// re-enable to have the names in the binary.
- fmt.Fprintf(ftable, "var %sStatenames = [...]string{", prefix)
+ ftable.WriteRune('\n')
+ fmt.Fprintf(ftable, "var %sStatenames = [...]string{\n", prefix)
// for i:=TOKSTART; i<=ntokens; i++ {
// fmt.Fprintf(ftable, "\t%q,\n", tokset[i].name);
// }
@@ -2819,7 +2820,7 @@
//
func aoutput() {
ftable.WriteRune('\n')
- fmt.Fprintf(ftable, "const %sLast = %v\n\n", prefix, maxa+1)
+ fmt.Fprintf(ftable, "const %sLast = %v\n", prefix, maxa+1)
arout("Act", amem, maxa+1)
arout("Pact", indgo, nstate)
arout("Pgo", pgo, nnonter+1)
@@ -2901,6 +2902,7 @@
arout("Tok2", temp1, c+1)
// table 3 has everything else
+ ftable.WriteRune('\n')
fmt.Fprintf(ftable, "var %sTok3 = [...]int{\n\t", prefix)
c = 0
for i = 1; i <= ntokens; i++ {
@@ -3013,7 +3015,8 @@
func arout(s string, v []int, n int) {
s = prefix + s
- fmt.Fprintf(ftable, "var %v = [...]int{\n", s)
+ ftable.WriteRune('\n')
+ fmt.Fprintf(ftable, "var %v = [...]int{", s)
for i := 0; i < n; i++ {
if i%10 == 0 {
fmt.Fprintf(ftable, "\n\t")