News for hackers. Stuff that matters.
Re:Just Write the Parser by epistasis on Wednesday October 21, 2020 @04:44PM (#24851985)
There's been a ton of code that I've written that in retrospect, I should never have written.

But I've never regretted when I wrote a parser. Maybe because it takes such a large activation energy to get over the hump and actually do it, that I only do it when absolutely necessary. But it always seems easier and more useful than I thought before doing it.

Now that this post has prompted that realization, I wonder if it will stay true...

Re:Just Write the Parser by pianoben on Thursday October 22, 2020 @12:01AM (#24854754)
I have _absolutely_ regretted writing a parser by hand. Once I replaced it with an ANTLR grammar and a comparatively-trivial bit of glue, my thrift parser became not only easier to refactor but more reliable.

My hand-written recursive descent parser was a perennial source of bugs, where ANTLR has yielded almost none. Some fiddly things I was doing with comments became much easier, if not effortless.

I highly, HIGHLY recommend at least starting with a compiler-generator like ANTLR. The "activation cost" of your project will be much lower, and you may find that you never actually _need_ the level of control you give up.