Open modulovalue opened 5 months ago
Honestly I hadn't thought about classifying the nature or structure of ambiguities in the manner you describe. I'll tell you three reasons why:
If an (LR1-) ambiguous grammar most naturally reflects the semantic structure of some language, I'd rather a grammar author be able to use that ambiguous grammar directly rather than forcing them to recast the grammar in different terms.
For designed formal languages, grammars that are hard for computers to parse tend to also be harder for people to deal with. For natural language, there's generally plenty of inherent ambiguity even at the lexical level. These might benefit from a completely different parsing strategy. Personally I have mainly dealt with formal languages, but perhaps some day I'll try something else. (I have a few ideas.)
Hello again @kjosib!
Have you ever tried finding associativity and precedence related ambiguities just from the structure of the CFG?
Assuming there's no hidden recursion, this seems to be doable:
X -> _ X ; X -> X _
then that's a precedence-related ambiguityX -> X _ X
(special case of precedence)However, to be complete, we'd have to make sure we do consider hidden recursion.
There's also the case where recursion is not necessarily hidden, but just indirect:
X -> X _ O ; O -> _ X
.Since you have spent some time on thinking about hidden recursion, I'd love to hear your thoughts on this topic. Have you perhaps tried doing something similar before with booze-tools? Do you know of any prior work trying to do something similar?