Re:Go 1.3+ Compiler Overhaul
by lucian1900 on Thursday December 19, 2013 @10:27AM
(#6935132)
Even if written in C, generating source code is trivial compared to parsing. The translator doesn't have to output the prettiest code either, since there's gofmt/fix.
Notation: T[A,B] : Translates from A to B
The OP wants to develop T[C, Go]. The question is which language should T[C,Go] be written in?
Option #1: If T[C,Go] is written in C, then it can use an existing C parsing library to parse C and then emit Go. Here parsing will be easier, but emitting Go will be laborious to write in C (since C is very low level).
Option #2: If T[C,Go] is written in Go, then the parent claims that C parsing will have to be freshly developed in Go. This will be a pain but the Go emitting code will be easier to write in Go.
However, I think the problem with option #2 (parsing) can be avoided if one uses the parsing library that is assumed to be already available in C. Since Go can interface with C code[1], the parser need not be reinvented.
[1] : http://golang.org/cmd/cgo/