From 2eeab323ad516dca2fb6f222a1810b3fadd61fc1 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Wed, 15 May 2013 12:08:51 +0800 Subject: [PATCH] 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 --- src/cmd/yacc/yacc.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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]) -- 2.48.1