Commit 3d2c4df9 authored by ChaiShushan's avatar ChaiShushan Committed by Russ Cox

cmd/yacc: gofmt y.go

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/36950043
parent ff6b9223
...@@ -49,6 +49,8 @@ import ( ...@@ -49,6 +49,8 @@ import (
"bytes" "bytes"
"flag" "flag"
"fmt" "fmt"
"go/format"
"io/ioutil"
"os" "os"
"strings" "strings"
"unicode" "unicode"
...@@ -3212,6 +3214,7 @@ func exit(status int) { ...@@ -3212,6 +3214,7 @@ func exit(status int) {
if ftable != nil { if ftable != nil {
ftable.Flush() ftable.Flush()
ftable = nil ftable = nil
gofmt()
} }
if foutput != nil { if foutput != nil {
foutput.Flush() foutput.Flush()
...@@ -3224,6 +3227,18 @@ func exit(status int) { ...@@ -3224,6 +3227,18 @@ func exit(status int) {
os.Exit(status) os.Exit(status)
} }
func gofmt() {
src, err := ioutil.ReadFile(oflag)
if err != nil {
return
}
src, err = format.Source(src)
if err != nil {
return
}
ioutil.WriteFile(oflag, src, 0666)
}
var yaccpar string // will be processed version of yaccpartext: s/$$/prefix/g var yaccpar string // will be processed version of yaccpartext: s/$$/prefix/g
var yaccpartext = ` var yaccpartext = `
/* parser for yacc output */ /* parser for yacc output */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment