Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If my grammar looked like that, I'd throw it away and start over, because the problem to me appears to be not quite having a clear idea of what the grammar is expressing.

That's fine if you are working in a purely academic domain, or you're just having fun writing something on your free time.

In production settings, you need to keep extending whatever language you have. The alternative is having to start to maintain two separate parsers and a migration tool, and be stuck with that for years.

The point is that being able to throw away code is a luxury that virtually no one is able to afford.



No, I'm not talking about an academic setting.

This is not about the language but about his expression of it in this specific instance of the grammar.

As the article makes clear, he didn't understand the language, and my claim is that is to a large extent down to how it is expressed.

Not throwing away this specific grammar instance is something you can't afford.


sometimes having an lalr parser generator tell you where the ambiguities are in your grammar can be a useful step to understanding the language you're trying to describe. you're probably right that once you do understand it, you should throw away the grammar given as an example and write a new one ;)


Sure, especially for anyone not used to writing parsers using a parser generator is a good way of validating assertions about it. But for that parser, just starting by cleaning it up would be a big improvement irrespective of formalism. Even if you get an unambiguous parser, if you can't read the grammar you'll end up with nasty surprises anyway...


agreed!


> In production settings, you need to keep extending whatever language you have.

Then the hard work of leaving behind simplistic, ambiguous, imprecise, inefficient grammar specifications has already been done (mostly) and you are ready to add small new features without serious rewrites.


Can't you prove that your new grammar describes the same language as your old one, or mechanically concert both to some normal form and check that they're identical or something like that?


What do you mean? Stuff gets refactored all the time.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: