mirror of
https://github.com/golang/go.git
synced 2025-11-10 05:31:03 +00:00
cmd/compile/internal/gc: use new AST parser
Introduce a new noder type to transform package syntax's AST into gc's Node tree. Hidden behind a new -newparser flag. Change-Id: Id0e862ef6196c41533876afc4ec289e21d422d18 Reviewed-on: https://go-review.googlesource.com/27198 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
117793624b
commit
2ff463948c
3 changed files with 1139 additions and 20 deletions
|
|
@ -30,6 +30,8 @@ var (
|
|||
goarch string
|
||||
goroot string
|
||||
buildid string
|
||||
|
||||
flag_newparser bool
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -189,6 +191,7 @@ func Main() {
|
|||
obj.Flagcount("live", "debug liveness analysis", &debuglive)
|
||||
obj.Flagcount("m", "print optimization decisions", &Debug['m'])
|
||||
flag.BoolVar(&flag_msan, "msan", false, "build code compatible with C/C++ memory sanitizer")
|
||||
flag.BoolVar(&flag_newparser, "newparser", false, "use new parser")
|
||||
flag.BoolVar(&nolocalimports, "nolocalimports", false, "reject local (relative) imports")
|
||||
flag.StringVar(&outfile, "o", "", "write output to `file`")
|
||||
flag.StringVar(&myimportpath, "p", "", "set expected package import `path`")
|
||||
|
|
@ -321,25 +324,14 @@ func Main() {
|
|||
}
|
||||
|
||||
linehistpush(infile)
|
||||
|
||||
f, err := os.Open(infile)
|
||||
if err != nil {
|
||||
fmt.Printf("open %s: %v\n", infile, err)
|
||||
errorexit()
|
||||
}
|
||||
bin := bufio.NewReader(f)
|
||||
|
||||
// Skip initial BOM if present.
|
||||
if r, _, _ := bin.ReadRune(); r != BOM {
|
||||
bin.UnreadRune()
|
||||
}
|
||||
|
||||
block = 1
|
||||
iota_ = -1000000
|
||||
|
||||
imported_unsafe = false
|
||||
|
||||
parse_file(bin)
|
||||
if flag_newparser {
|
||||
parseFile(infile)
|
||||
} else {
|
||||
oldParseFile(infile)
|
||||
}
|
||||
if nsyntaxerrors != 0 {
|
||||
errorexit()
|
||||
}
|
||||
|
|
@ -348,9 +340,7 @@ func Main() {
|
|||
// for the line history to work, and which then has to be corrected elsewhere,
|
||||
// just add a line here.
|
||||
lexlineno++
|
||||
|
||||
linehistpop()
|
||||
f.Close()
|
||||
}
|
||||
timings.Stop()
|
||||
timings.AddEvent(int64(lexlineno-lexlineno0), "lines")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue