]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove unneeded error message cleanup pass
authorMatthew Dempsky <mdempsky@google.com>
Wed, 9 Dec 2015 20:53:28 +0000 (12:53 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 9 Dec 2015 21:25:05 +0000 (21:25 +0000)
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 <bradfitz@golang.org>
src/cmd/compile/internal/gc/parser.go
src/cmd/compile/internal/gc/subr.go

index a3f30793939f1528126a8c45ef0d2344596813ec..c3f131fe7641ad16b229be8874b131199027c27c 100644 (file)
@@ -142,7 +142,6 @@ func (p *parser) syntax_error(msg string) {
        var tok string
        switch p.tok {
        case LLITERAL:
-               // this is also done in Yyerror but it's cleaner to do it here
                tok = litbuf
        case LNAME:
                if p.sym_ != nil && p.sym_.Name != "" {
index 163ecbc34c10f016c212ec36237c0ffe6b5ade53..0d25ddf2af9cd8904a67dafebbe6f1899a7161c5 100644 (file)
@@ -134,16 +134,6 @@ func Yyerror(format string, args ...interface{}) {
                        return
                }
 
-               // The grammar has { and LBRACE but both show up as {.
-               // Rewrite syntax error referring to "{ or {" to say just "{".
-               // The grammar has ? and @ but only for reading imports.
-               // Silence them in ordinary errors.
-               msg = strings.Replace(msg, "{ or {", "{", -1)
-               msg = strings.Replace(msg, " or ?", "", -1)
-               msg = strings.Replace(msg, " or @", "", -1)
-
-               msg = strings.Replace(msg, "LLITERAL", litbuf, -1)
-
                yyerrorl(int(lexlineno), "%s", msg)
                return
        }