How does the Go1 compiler work?

I went about Go for about a month for a school project, and I noticed packages go / ast, go / token, go / parser, etc. in the src / pkg / go folder. However, the gc compiler was based on C files located in src / cmd / gc.

My question is about the new go command in Go1, which builds and runs programs: does this tool depend on the packages I referenced above? those. if I add a new token to /go/token/token.go, will it be recognized by the new go compiler?

+3
source share
3 answers

The Go compiler is written in pure C and does not use packages under go/. In the Go source tree, his lexer lives in src / cmd / gc / lex.c, and his Bison grammar lives in src / cmd / gc / go.y.

go/ , godoc, gofmt go. , - Go Go, .

+5

(18 2013 .), C :

" 1.3+ " (Russ Cox)

, go/parser, " 5" :

(, ) go/parser go/types.
API go/parser go/types - , ( , Go 1).
API.


, , , , "" Tour of Go" ( 2012 .) :

, Go , .
, Im , , .

" - Go Go, Go Go?", ( , 2012 ):

. Go Go, Go, , theres - , .

, , , . , , , .

+2

, ?

"go"

/go/token/token.go, go?

.

+1
source

Source: https://habr.com/ru/post/1661352/


All Articles