]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/syntax: add BasicLit.Bad field for lexical errors
authorRobert Griesemer <gri@golang.org>
Thu, 29 Aug 2019 04:56:47 +0000 (21:56 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 29 Aug 2019 23:37:01 +0000 (23:37 +0000)
commit117400ec095335f24e5363f61d60f8baad6be3ce
treeffa7bafc79f21110766afc3bb8f96d3dad1974bd
parentbf36219cdd1d354d58107ed8903679f538948154
cmd/compile/internal/syntax: add BasicLit.Bad field for lexical errors

The new (internal) field scanner.bad indicates whether a syntax error
occurred while scanning a literal; the corresponding scanner.lit
string may be syntactically incorrect in that case. Store the value
of scanner.bad together with the scanner.lit in BasicLit.

Clean up error handling so that all syntactic errors use one of the
scanner's error reporting methods which also set scanner.bad. Make
use of the new field in a few places where we used to track a prior
error separately.

Preliminary step towards fixing #32133 in a comprehensive manner.

Change-Id: I4d79ad6e3b50632dd5fb3fc32ca3df0598ee77b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/192278
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/syntax/nodes.go
src/cmd/compile/internal/syntax/parser.go
src/cmd/compile/internal/syntax/scanner.go
src/cmd/compile/internal/syntax/scanner_test.go
src/cmd/compile/internal/syntax/tokens.go