Referring to this Question, where an answer is stating that all Type 3 languages are LL(1), I'd like to know if all Type 3 grammars are possibly LL(1).
If not, why is it so? Are there maybe ambiguous grammars in the set of the Type 3 grammars?
Referring to this Question, where an answer is stating that all Type 3 languages are LL(1), I'd like to know if all Type 3 grammars are possibly LL(1).
If not, why is it so? Are there maybe ambiguous grammars in the set of the Type 3 grammars?
Chomsky hierarchy is primarily a hierarchy of grammars, not of languages. As stated in Wikipedia:
The Chomsky hierarchy (occasionally referred to as Chomsky-Schützenberger hierarchy) is a containment hierarchy of classes of formal grammars.
Type 3 grammars are characterized by the fact that they have to have only left linear rules (i.e., productions), or only right linear rules, plus possibly an empty rule for the initial non-terminal symbol. For any language, both forms exist.
A rule is left linear iff its right hand side (RHS) is composed of a terminal symbol, possibly preceded by a single non-terminal.
A rule is right linear iff its right hand side (RHS) is composed of a terminal symbol, possibly followed by a single non-terminal.
(There are small variants of these definitions, allowing for a terminal string of any length, instead of a single terminal)
When the language is not finite, some of the rules are necessarily recursive. But a left linear rules that is recursive is necessarily left recursive. Hence the grammar is not LL(1).
Hence some type 3 grammars, even with the strict definition above, are not LL(1).