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:
Matthew Dempsky 2016-08-30 16:31:53 -07:00
parent 69e7e8a696
commit ee161e8591
10 changed files with 169 additions and 129 deletions

View file

@ -22,7 +22,7 @@ var src = flag.String("src", "parser.go", "source file to parse")
var verify = flag.Bool("verify", false, "verify idempotent printing")
func TestParse(t *testing.T) {
_, err := ReadFile(*src, nil, 0)
_, err := ReadFile(*src, nil, nil, 0)
if err != nil {
t.Fatal(err)
}
@ -52,7 +52,7 @@ func TestStdLib(t *testing.T) {
if debug {
fmt.Printf("parsing %s\n", filename)
}
ast, err := ReadFile(filename, nil, 0)
ast, err := ReadFile(filename, nil, nil, 0)
if err != nil {
t.Fatal(err)
}
@ -133,7 +133,7 @@ func verifyPrint(filename string, ast1 *File) {
panic(err)
}
ast2, err := ReadBytes(buf1.Bytes(), nil, 0)
ast2, err := ReadBytes(buf1.Bytes(), nil, nil, 0)
if err != nil {
panic(err)
}