Commit 2eeab323 authored by Shenghou Ma's avatar Shenghou Ma

cmd/yacc: don't emit line comment when -l is given

Fixes #5447.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9343045
parent fae362e9
...@@ -1130,7 +1130,9 @@ func emitcode(code []rune, lineno int) { ...@@ -1130,7 +1130,9 @@ func emitcode(code []rune, lineno int) {
writecode(line) writecode(line)
if !fmtImported && isPackageClause(line) { if !fmtImported && isPackageClause(line) {
fmt.Fprintln(ftable, `import __yyfmt__ "fmt"`) 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 fmtImported = true
} }
} }
...@@ -2193,8 +2195,10 @@ nextk: ...@@ -2193,8 +2195,10 @@ nextk:
func output() { func output() {
var c, u, v int var c, u, v int
fmt.Fprintf(ftable, "\n//line yacctab:1\n") if !lflag {
fmt.Fprintf(ftable, "var %sExca = []int{\n", prefix) fmt.Fprintf(ftable, "\n//line yacctab:1")
}
fmt.Fprintf(ftable, "\nvar %sExca = []int{\n", prefix)
noset := mkset() noset := mkset()
...@@ -2963,7 +2967,9 @@ func others() { ...@@ -2963,7 +2967,9 @@ func others() {
} }
// copy yaccpar // 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) parts := strings.SplitN(yaccpar, prefix+"run()", 2)
fmt.Fprintf(ftable, "%v", parts[0]) fmt.Fprintf(ftable, "%v", parts[0])
......
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