COMPILER DESIGN

INTRODUCTION TO COMPILER DESIGN

OVERVIEW OF COMPILERS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A grammar that is both left and right recursive for a non-terminal is
A
Ambiguous
B
Unambiguous
C
Information is not sufficient to decide whether it is ambiguous or Unambiguous.
D
None of the above
Explanation: 

Detailed explanation-1: -A grammar that is both left and right recursive for a non-terminal, isa)Ambiguousb)Unambiguousc)Information is not sufficient to decide whether it is ambiguous or unambiguousd)None of the aboveCorrect answer is option ā€˜Cā€™.

Detailed explanation-2: -With right recursion, no reduction takes place until the entire list of elements has been read; with left recursion, a reduction takes place as each new list element is encountered. Left recursion can therefore save a lot of stack space.

Detailed explanation-3: -The grammar which is both left recursive and right recursive is always ambiguous.

Detailed explanation-4: -In computer science, a grammar is informally called a recursive grammar if it contains production rules that are recursive, meaning that expanding a non-terminal according to these rules can eventually lead to a string that includes the same non-terminal again. Otherwise it is called a non-recursive grammar.

There is 1 question to complete.