mirror of
https://github.com/golang/go
synced 2024-11-12 09:50:21 -07:00
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 <iant@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
8389e7cfa9
commit
546836556d
@ -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")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user