I've been dabbling with Go for about a month for a school project and I noticed the go/ast, go/token, go/parser, etc. packages in the src/pkg/go folder. However, the gc compiler was based on C files located in src/cmd/gc.
My question regards the new go command in Go1 that builds and runs programs: does this tool depend on the packages I referenced above? i.e. if I added a new token to /go/token/token.go, would it be recognized by the new go compiler?
Note (December 18th, 2013), there are plans to move the compiler from C to Go itself:
In that context packages like go/parser will be involved, and the "Phase 5" mentions:
This is probably a testimony on how stable the language has become, since the old "A Tour of Go" (June 2012) mentioned before clearly stated:
The question "Is there any plan to bootstrap Go in Go, to write the Go compiler in Go?" mentioned at the time (again, June 2012):
does this tool depend on the packages I referenced above?
The 'go' tool does depend on those packages
if I added a new token to /go/token/token.go, would it be recognized by the new go compiler?
No.
The Go compiler is written in pure C and does not use the packages under
go/
. In the Go source tree, its lexer lives in src/cmd/gc/lex.c and its Bison grammar is src/cmd/gc/go.y.The
go/
packages are used in tools like godoc, gofmt, and various go tool subcommands. Maybe someday they can be used to write a Go compiler in Go as well, but no one's gotten very far on that path yet.