4 ms·
Just because the PEG doesn't have ambiguities doesn't mean the grammar you meant to recognize doesn't have one. What I mean is: PEGs give you a false sense of c
by frabert 5y ago
Just because the PEG doesn't have ambiguities doesn't mean the grammar you meant to recognize doesn't have one. What I mean is: PEGs give you a false sense of confidence by making you feel like you solved all your grammar's issues. In reality, you need to think really carefully about what your PEG is doing, because it's not going to warn you. As you said, PEGs are never ambiguous.
- chrisseaton 5y agoWell yeah if the grammar you wrote doesn't match what you intended to write then it's not going to work. Not sure how that's saying anything useful though? If you write the wrong grammar with any parsing system it's also not going to work.
- frabert 5y agoMost other parser generator systems give you indication that what you're writing is probably wrong, by stating e.g. that a grammar is ambiguous. S := A '+' A | A '*' A A := ... If you do that in most PEG systems I've tried, you're just going to get the wrong result with no indication of what might have gone wrong, unless you know where to look.
- chrisseaton 5y agoBut that's the point - other parsing systems let you design an ambiguous language and then tell you about it. PEGs don't let you design an ambiguous language in the first place. Unambiguous by construction.