From: Shenghou Ma Date: Wed, 15 May 2013 04:08:51 +0000 (+0800) Subject: cmd/yacc: don't emit line comment when -l is given X-Git-Tag: go1.2rc2~1511 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2eeab323ad516dca2fb6f222a1810b3fadd61fc1;p=gostls13.git 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 --- diff --git a/src/cmd/yacc/yacc.go b/src/cmd/yacc/yacc.go index 76b3aeac5d..7bc226699b 100644 --- a/src/cmd/yacc/yacc.go +++ b/src/cmd/yacc/yacc.go @@ -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])