4 ms·
Another note, recently Go stopped using yacc(bison).
by redbeard0x0a 11y ago
Another note, recently Go stopped using yacc(bison).
- biomcgary 11y agoI would appreciate a reference with an explanation about why that has changed. Is it to support code transformation?
- koenigdavidmj 11y agoThey recently did a mostly-automated rewrite of the compiler from C to Go. I expect it was easier to hand-rewrite the parser instead of writing a Go backend for yacc or converting the C parser that yacc generated.
- nordsieck 11y agoIt looks like there has been a version of yacc in the go source tree (that works with go, not c) for at least 11 months. https://github.com/golang/go/tree/master/src/cmd/yacc https://github.com/golang/go/tree/master/src/cmd/yacc
- gilgoomesh 11y agoHandwritten recursive descent parsers offer much more control than the output of a parser generator. Most major C/C++ compiler front-ends do this.
- vidarh 11y agoIn fact, very few production compilers use generated parsers - sooner or later they tend to end up with hand-written parsers for one reason or other. Particularly down to error reporting. Parser generators need to get much better before that will change.
- nostrademons 11y agoI wonder if it might have something to do with error reporting. The usual way to handle error messages in a CFG is to make a superset of the grammar that contains all likely mistakes, along with custom error messages for each one. As you can imagine, the resulting grammars get pretty hairy. You also have more information available for reporting & recovery with a hand-written parser: think, for example, of how Clang can spell-correct mistyped keywords, something that's not possible without the ability to interpret an identifier as a keyword if it happens to be a certain edit-distance off.
- binarycrusader 11y agoThe actual commit: https://groups.google.com/forum/#!searchin/golang-checkins/russ$20parser/golang-checkins/R3sSjEVYC9Q/w7EvtqQwEQAJ https://groups.google.com/forum/#!searchin/golang-checkins/r... From what I recall reading about the change, it was believed it would allow them more flexibility in the frontend, and they greatly preferred to write the parser in Go instead of yacc. Also, at this point, they felt this would also make it easier for others to contribute improvements to the project.
- sleepydog 11y agohttps://www.reddit.com/r/golang/comments/46bd5h/ama_we_are_the_go_contributors_ask_us_anything/d03zx6f https://www.reddit.com/r/golang/comments/46bd5h/ama_we_are_t...
- haberman 11y agoThanks for the note, I will add this to the article when I get a chance!