summaryrefslogtreecommitdiff
path: root/src/cmd/yacc/yacc.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/yacc/yacc.go')
-rw-r--r--src/cmd/yacc/yacc.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cmd/yacc/yacc.go b/src/cmd/yacc/yacc.go
index c53dc3b74..c53403266 100644
--- a/src/cmd/yacc/yacc.go
+++ b/src/cmd/yacc/yacc.go
@@ -49,6 +49,8 @@ import (
"bytes"
"flag"
"fmt"
+ "go/format"
+ "io/ioutil"
"os"
"strings"
"unicode"
@@ -3212,6 +3214,7 @@ func exit(status int) {
if ftable != nil {
ftable.Flush()
ftable = nil
+ gofmt()
}
if foutput != nil {
foutput.Flush()
@@ -3224,6 +3227,18 @@ func exit(status int) {
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 yaccpartext = `
/* parser for yacc output */