]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/yacc: don't emit line comment when -l is given
authorShenghou Ma <minux.ma@gmail.com>
Wed, 15 May 2013 04:08:51 +0000 (12:08 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Wed, 15 May 2013 04:08:51 +0000 (12:08 +0800)
Fixes #5447.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9343045

src/cmd/yacc/yacc.go

index 76b3aeac5d6217e05e1a9e6d879b2ba99df2e1f2..7bc226699b2065e694cb6f6420a014a9688ba2ff 100644 (file)
@@ -1130,7 +1130,9 @@ func emitcode(code []rune, lineno int) {
                writecode(line)
                if !fmtImported && isPackageClause(line) {
                        fmt.Fprintln(ftable, `import __yyfmt__ "fmt"`)
-                       fmt.Fprintf(ftable, "//line %v:%v\n\t\t", infile, lineno+i)
+                       if !lflag {
+                               fmt.Fprintf(ftable, "//line %v:%v\n\t\t", infile, lineno+i)
+                       }
                        fmtImported = true
                }
        }
@@ -2193,8 +2195,10 @@ nextk:
 func output() {
        var c, u, v int
 
-       fmt.Fprintf(ftable, "\n//line yacctab:1\n")
-       fmt.Fprintf(ftable, "var %sExca = []int{\n", prefix)
+       if !lflag {
+               fmt.Fprintf(ftable, "\n//line yacctab:1")
+       }
+       fmt.Fprintf(ftable, "\nvar %sExca = []int{\n", prefix)
 
        noset := mkset()
 
@@ -2963,7 +2967,9 @@ func others() {
        }
 
        // copy yaccpar
-       fmt.Fprintf(ftable, "\n//line yaccpar:1\n")
+       if !lflag {
+               fmt.Fprintf(ftable, "\n//line yaccpar:1\n")
+       }
 
        parts := strings.SplitN(yaccpar, prefix+"run()", 2)
        fmt.Fprintf(ftable, "%v", parts[0])