COMPILER DESIGN

TOOLS AND TECHNIQUES FOR COMPILER DESIGN

MISCELLENOUS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of the following grammar can be converted in LL(1) parser?
A
Grammar contain Left recursion
B
Grammar contain Left factoring
C
Grammar contain Left Factoring and right recursion
D
None of the above
Explanation: 

Detailed explanation-1: -In many cases we can convert an non-LL(1) grammar to an LL(1) grammar. Stat −→ if Exp then Stat end Stat −→ if Exp then Stat else Stat end Stat −→ other The terminal if will be in the selector sets of the first to productions. Is that all there is to it? The above methods will convert many grammars to LL(1) form.

Detailed explanation-2: -The correct answer is option 3. Concept: Non-recursive descent parser or table-driven is also known as LL(1) parser. This parser follows the leftmost derivation (LMD).

Detailed explanation-3: -Simple answer:A grammar is said to be an LL(1), if the associated LL(1) parsing table has atmost one production in each table entry. As [S, b] contains two Productions there is a confusion as to which rule to choose.So it is not LL(1). Some simple checks to see whether a grammar is LL(1) or not.

There is 1 question to complete.