|
|
|
|
|
by cakoose
73 days ago
|
|
> it avoids ambiguity by using ordered choice (the first matching rule wins) PEG parsing tool authors often say that ordered choice solves the problem of ambiguity, that's very misleading. Yes, ordered choice is occasionally useful as a way to resolve grammatic overlap. But as a grammar author, it's more common for me to want to express unordered choice between two sub-grammars. A tool that supports unordered choice will then let you know when you have an unexpected ambiguity. PEG-based tools force you to use ordered choice for everything. You may be surprised later to find out that your grammar was actually ambiguous, and the ambiguity was "resolved" somewhat arbitrarily by picking the first sub-grammar. > This makes working with Ohm/PEGs less painful in the initial phase of a project. I do agree with this. But then what happens in the later phases? Do you switch to a tool that supports unordered choice to see if you have any ambiguities? And potentially have to change your grammar to fix them? |
|