4 ms·
The only limit I've ever reached with BNF is that you cannot express permutations of given set of rules, you really have to write every possibility literally.
by sixthDot 3y ago
The only limit I've ever reached with BNF is that you cannot express permutations of given set of rules, you really have to write every possibility literally.
- _anti_meh 3y ago[flagged]
- owlstuffing 3y agoPersonally, I would avoid a language that pushed that limit
- vidarh 3y agoI interpreted (maybe misinterpreted) that as lamenting having to write out priorities of operators, as that's the most common set of rules in BNF where you end up with near identical permutations. E.g: term = term2 [op1 term] term2 = term3 [op2 term2] ... and so on for every precedence level. A lot of BNF grammars for simpler languages are dominated by rules following that pattern.
- vidarh 3y agoIt takes fairly small extensions to BNF, though. When I write parser generators (sentences I didn't think I'd write, but it's been quite a few), there are a few things I'd often add extra constructs for. One being lists (term = value ("," term)? or variants occur often enough that introducing a list syntax that reduces pointless recursion is helpful), and other being patterns, e.g. when defining operator precedence, which I'm guessing is what you're thinking of? Being able to recursively generate a rule-set where each level takes the head of a list is very useful.