I read that no LL(1) grammar can be ambiguous.
Can we just make a LL(1) predictive parser table for a grammar to determine whether it's ambiguous? If the grammar is not LL(1), can we say that grammar is ambiguous?
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.Sign up to join this community
If the grammar is not LL(1), can we say that grammar is ambiguous?
Euh, no. A grammar is unambiguous if for every word in its language there exists exactly one derivation-tree for it in the grammar.
Parsing is a way to find that derivation, given the string, preferably in some efficient way. Several classes of grammars were defined that have efficient parsing methods, for example LL(1) grammars.
A grammar can be non-LL(1), and still be unambiguous. For instance when we reverse an LL(1) grammar (that is, take the mirror image of the RHS of every production) the result still is unambiguous: mirroring the original unique derivation trees. But it cannot be parsed in an LL fashion, rather its reverse...