TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to write a parser in Go

85 pointsby beyangover 6 years ago

6 comments

kalekoldover 6 years ago
Or you can read this: <a href="https:&#x2F;&#x2F;interpreterbook.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;interpreterbook.com&#x2F;</a>
评论 #17927881 未加载
weberc2over 6 years ago
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 &#x2F;r&#x2F;programming?—yesterday, incidentally).
gameswithgoover 6 years ago
Another very good take on this topic that really was the first thing that made it all click for me:<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=HxaD_trXwRE" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=HxaD_trXwRE</a>
lloekiover 6 years ago
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&#x27;ve been using PEG&#x2F;Packrat implementations providing a more &quot;native&quot; experience to great effect lately, notably ruby&#x27;s treetop and golang&#x27;s pointlander&#x2F;peg.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;cjheath&#x2F;treetop" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cjheath&#x2F;treetop</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;pointlander&#x2F;peg" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pointlander&#x2F;peg</a>
rijojaover 6 years ago
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&#x27;t really remember doing why. Might&#x27;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.
jcelerierover 6 years ago
yuck, I&#x27;d take boost.spirit every day over this
评论 #17926430 未加载