Skip to content

Commit 07f9c25

Browse files
committed
cmd/compile: remove unneeded error message cleanup pass
This code used to be necessary because of the error messages generated by the YACC-based parser, but they're no longer relevant under the new recursive descent parser: - LBRACE no longer exists, so "{ or {" can never occur. - The parser never generates error messages about "@" or "?" now (except in import sections, where they're actually legitimate). - The s/LLITERAL/litbuf/ substitution is handled in p.syntax_error. Change-Id: Id39f747e4aa492c5830d14a47b161920bd4589ad Reviewed-on: https://go-review.googlesource.com/17690 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 0b37a6f commit 07f9c25

File tree

2 files changed

+0
-11
lines changed

2 files changed

+0
-11
lines changed

src/cmd/compile/internal/gc/parser.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ func (p *parser) syntax_error(msg string) {
142142
var tok string
143143
switch p.tok {
144144
case LLITERAL:
145-
// this is also done in Yyerror but it's cleaner to do it here
146145
tok = litbuf
147146
case LNAME:
148147
if p.sym_ != nil && p.sym_.Name != "" {

src/cmd/compile/internal/gc/subr.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,6 @@ func Yyerror(format string, args ...interface{}) {
134134
return
135135
}
136136

137-
// The grammar has { and LBRACE but both show up as {.
138-
// Rewrite syntax error referring to "{ or {" to say just "{".
139-
// The grammar has ? and @ but only for reading imports.
140-
// Silence them in ordinary errors.
141-
msg = strings.Replace(msg, "{ or {", "{", -1)
142-
msg = strings.Replace(msg, " or ?", "", -1)
143-
msg = strings.Replace(msg, " or @", "", -1)
144-
145-
msg = strings.Replace(msg, "LLITERAL", litbuf, -1)
146-
147137
yyerrorl(int(lexlineno), "%s", msg)
148138
return
149139
}

0 commit comments

Comments
 (0)