9 ms·
Couple of reasons. 1) Because I'm a fan of few dependencies and lex/yacc are non-Go dependencies. 2) I've never used them and it'd probably take me longer to le
by benhoyt 8y ago
Couple of reasons. 1) Because I'm a fan of few dependencies and lex/yacc are non-Go dependencies. 2) I've never used them and it'd probably take me longer to learn them than hand-write a lexer and parser. 3) Writing a lexer is trivial, and writing a recursive-descent parser is fun and not that hard.
As to the state of lexing/parsing in the Go world. There's a simple scanner (text/scanner) in the stdlib. I've run across this quite neat parser library that's based off structs and tags: https://github.com/alecthomas/participle https://github.com/alecthomas/participle ... but I really don't know the landscape very well.