Is there a way to define ambiguity in grammar?

We study ambiguity in a class, and the following grammar has been cited as an example of an ambiguous grammar. I just don’t see how ambiguous it is. Is there a set of patterns or methods that people use to determine ambiguity, or is it just a logic puzzle where you need to work through combinations to find an ambiguous sentence in a grammar? The examples I read on the Internet basically got an ambiguous offer, but how do you find this offer in the first place? I would be grateful for any help, thanks.

< stmt_list> ==> < stmt> | < stmt> ; < stmt_list> < var> ==> A | B | C < stmt> ==> < var> + < var> | < var> - < var> | < var> 
+6
source share
1 answer

In general, it determines whether a grammar is ambiguous or not, is unsolvable. So yes, the search for an ambiguous sentence in grammar comes down to a very complex logical puzzle. However, the solution of specific cases and the search for heuristics is an active area of ​​research. Here is a pretty good tool for finding ambiguity: http://www.brics.dk/grammar/ . The web page contains a link to a paper explaining how this works, although honestly, that goes over my head.

+2
source

All Articles