DANGLING ELSE PROBLEM:
S->iEtSS' / a
S'->∊/ eS
but ALL DCFG ARE UNAMBIGUOUS . so " how can this DCFG be ambiguous?"
Given CFG is "ambiguous" as you told. Is it deterministic? If so there must be a LR(k) grammar for it. This is not the case here - See this.
And answer to your question is NO - because that is the definition of inherent ambiguity. If a language is inherently ambiguous it can have no unambiguous grammar possible. Now, no DCFL is inherently ambiguous - any DCFL must have some unambiguous grammar.
Some facts:
Quoting from Wikipedia:
Unambiguous grammars do not always generate a DCFL. For example, the language of even-length palindromes on the alphabet of 0 and 1 has the unambiguous context-free grammar S → 0S0 | 1S1 | ε. An arbitrary string of this language cannot be parsed without reading all its letters first which means that a pushdown automaton has to try alternative state transitions to accommodate for the different possible lengths of a semi-parsed string
Summary of the solution: 1. Each DCFL can be generated by a corresponding LR(k) grammar and each LR(k) grammar generates one DCFL (one-to-one correspondence). 2. A language can be generated by more than one grammar, so for each DCFL an unambiguous LR(k) grammar do exists ( means, no DCFL is inherently ambiguous). 3. Each LR(k) grammar is unambiguous grammar, but each unambiguous grammar need not to be LR(k). 4. A language can only be inherently ambiguous while there is no such concept of "inherently ambiguous grammar". 5. An inherently ambiguous language can only be non-determinstic while an non-deterministic language may or may not be inherently ambiguous. For example there are many CFLs which are not inherently ambiguous, while there are such CFLs also which are inherently ambiguous. Cheers!!
64.3k questions
77.9k answers
244k comments
80.0k users