2 ms·
Great work. Reimplementing a practical and useful mini-language in another language is always a useful exercise. I'm curious though, why code the lexer and par
by wenc 8y ago
Great work. Reimplementing a practical and useful mini-language in another language is always a useful exercise.
I'm curious though, why code the lexer and parser by hand? What's the state of lexing/parsing in the Go world?
- benhoyt 8y agoCouple 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.