I played with this last year but couldn’t wrap my head around it. I don’t recall if it was poorly documented at the time or if it couldn’t handle something I was trying to do or if I was just depressed by the generated code quality, but I eventually gave up and tried rolling my own parser by hand. It was the first time I’d done such a thing and I didn’t really understand patterns for writing parsers so I eventually gave up there too. I’m really excited to read Thorsten Ball’s “How to write an Interpreter in Go” book which walks the reader through writing a parser by hand (his blog post about book-writing tools was on the front page here—or maybe it was /r/programming?—yesterday, incidentally).
Another very good take on this topic that really was the first thing that made it all click for me:<p><a href="https://www.youtube.com/watch?v=HxaD_trXwRE" rel="nofollow">https://www.youtube.com/watch?v=HxaD_trXwRE</a>
tl;dr: write a parser using goyacc, a yacc port that therefore has some impedance mismatch with Go. (go)yacc is LALR(1)<p>I've been using PEG/Packrat implementations providing a more "native" experience to great effect lately, notably ruby's treetop and golang's pointlander/peg.<p><a href="https://github.com/cjheath/treetop" rel="nofollow">https://github.com/cjheath/treetop</a><p><a href="https://github.com/pointlander/peg" rel="nofollow">https://github.com/pointlander/peg</a>
This project gives me I have a solution please give me a problem feeling. I remember looking into yacc a while ago, for some reason but I can't really remember doing why. Might've been for a configuration type of deal, but nowadays I just use json for that because it intersects other areas of the code and therefore saves time.