2 ms·
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
by epistasis 6y ago
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...
- pianoben 6y agoI 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.