mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: handle pragmas immediately with -newparser=1
Instead of saving all pragmas and processing them after parsing is finished, process them immediately during scanning like the current lexer does. This is a bit unfortunate because it means we can't use syntax.ParseFile to concurrently parse files yet, but it fixes how we report syntax errors in the presence of //line pragmas. While here, add a bunch more gcCompat entries to syntax/parser.go to get "go build -toolexec='toolstash -cmp' std cmd" passing. There are still a few remaining cases only triggered building unit tests, but this seems like a nice checkpoint. Change-Id: Iaf3bbcf2849857a460496f31eea228e0c585ce13 Reviewed-on: https://go-review.googlesource.com/28226 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
69e7e8a696
commit
ee161e8591
10 changed files with 169 additions and 129 deletions
|
|
@ -22,7 +22,7 @@ func TestScanner(t *testing.T) {
|
|||
defer src.Close()
|
||||
|
||||
var s scanner
|
||||
s.init(src, nil)
|
||||
s.init(src, nil, nil)
|
||||
for {
|
||||
s.next()
|
||||
if s.tok == _EOF {
|
||||
|
|
@ -51,7 +51,7 @@ func TestTokens(t *testing.T) {
|
|||
|
||||
// scan source
|
||||
var got scanner
|
||||
got.init(&bytesReader{buf}, nil)
|
||||
got.init(&bytesReader{buf}, nil, nil)
|
||||
got.next()
|
||||
for i, want := range sampleTokens {
|
||||
nlsemi := false
|
||||
|
|
@ -338,7 +338,7 @@ func TestScanErrors(t *testing.T) {
|
|||
} else if nerrors > 1 {
|
||||
t.Errorf("%q: got unexpected %q at pos = %d, line = %d", test.src, msg, pos, line)
|
||||
}
|
||||
})
|
||||
}, nil)
|
||||
|
||||
for {
|
||||
s.next()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue