3 ms·
Probably that it doesn't have ambiguities
by Calavar 4y ago
Probably that it doesn't have ambiguities
- eatonphil 4y agoIs that an important property? If so, why do you (*whoever) think so?
- Calavar 4y agoAs always, it depends on what your goal is. An unambiguous parser is easier to write tests for. It leads to fewer subtle "gotchas" where something syntax checks and compiles but is interpreted by the compiler as something very different than what the programmer intended. It's easier for third parties to write their own parsers and tooling for the language if they can target a formal grammar as opposed to the behavior of your Turing complete code. But sometimes you don't care about any of those things. Especially if you're talking about a language with a small surface area. Or if you have to deal with legacy stuff (for example, parsing something like C++ that is heavily context sensitive, in which case trying to shoehorn things into a formal CFG so you can feed it to a generator might actually make things much harder than they have to be).
- tomcam 4y agoNot always, and that’s a great question! But I can help you catch things that might not be obvious when your first create the grammar, even such simple things as ambiguous nested if statements or errors in string formatting DSL syntax.
- tomcam 4y ago* it can, not I can
- tomcam 4y agoThanks, that’s a better way of putting it.