From 546836556d202c9667ad6530710bae6a982d427e Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Mon, 10 Aug 2015 15:17:18 +1000 Subject: [PATCH] cmd/yacc: use %q to print strings in Toknames Fixes #12086 Belongs in 1.5 There remains a question of why the Statenames table's elements are not printed. What purpose does that serve? Change-Id: I83fd57b81d5e5065c3397a66ed457fc0d1c041bd Reviewed-on: https://go-review.googlesource.com/13462 Reviewed-by: Ian Lance Taylor Reviewed-by: Andrew Gerrand Reviewed-by: Russ Cox Reviewed-by: Matthew Dempsky --- src/cmd/yacc/yacc.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cmd/yacc/yacc.go b/src/cmd/yacc/yacc.go index 53c0fab174..a63c218b13 100644 --- a/src/cmd/yacc/yacc.go +++ b/src/cmd/yacc/yacc.go @@ -699,18 +699,20 @@ outer: } } - // put out names of token names + // put out names of tokens ftable.WriteRune('\n') fmt.Fprintf(ftable, "var %sToknames = [...]string{\n", prefix) for i := 1; i <= ntokens; i++ { - fmt.Fprintf(ftable, "\t\"%v\",\n", tokset[i].name) + fmt.Fprintf(ftable, "\t%q,\n", tokset[i].name) } fmt.Fprintf(ftable, "}\n") - // put out names of state names + // put out names of states. + // commented out to avoid a huge table just for debugging. + // re-enable to have the names in the binary. fmt.Fprintf(ftable, "var %sStatenames = [...]string{", prefix) // for i:=TOKSTART; i<=ntokens; i++ { - // fmt.Fprintf(ftable, "\t\"%v\",\n", tokset[i].name); + // fmt.Fprintf(ftable, "\t%q,\n", tokset[i].name); // } fmt.Fprintf(ftable, "}\n") -- 2.48.1