Compiler design miscellaneous


Compiler design miscellaneous

  1. Given the following expression grammar
    E → E * F | F + E | F
    E → F – | id
    Which of the following is true?









  1. View Hint View Answer Discuss in Forum

    ‘–’ has higher precedence than ‘*’ as ‘–’ is a leaf node in the tree formed using this whereas ‘*’ is not.

    Correct Option: B

    ‘–’ has higher precedence than ‘*’ as ‘–’ is a leaf node in the tree formed using this whereas ‘*’ is not.


  1. Which of the following statements is false?









  1. View Hint View Answer Discuss in Forum

    So (a) & (c) are, true.
    An ambiguous grammar can't be LR (K)
    So option (a) is false since an unambiguous grammar has unique right most derivation & left most derivations but both are not same. Hence (a) is correct option

    Correct Option: A

    So (a) & (c) are, true.
    An ambiguous grammar can't be LR (K)
    So option (a) is false since an unambiguous grammar has unique right most derivation & left most derivations but both are not same. Hence (a) is correct option



  1. Consider the grammar shonws below :
    S → CC
    C → cc/ d
    This grammar is









  1. View Hint View Answer Discuss in Forum

    First (S) = First (C) = {c,d} there are no multiple in single row of parsing table hence grammar is LL1
    Note : if we have A → B/C for grammar to be LL(1) first(B) intersection First(C) should be null otherwise grammar is not LL1. If First(B) contains epsilon then Follow(A) intersection First(C) should be null. Using this we can say grammar is LL(1) or not without constructing parsing table.
    An ∈ ∈ free LL(1) grammar is also SLR(1) and hence LALR(1) and LR(1) too.
    Since there is no conflict, the grammar is LL(1). We can construct a predictive parse table with no conflicts. This grammar also LR(0), SLR(1), CLR(1) and LALR(1).

    Correct Option: A

    First (S) = First (C) = {c,d} there are no multiple in single row of parsing table hence grammar is LL1
    Note : if we have A → B/C for grammar to be LL(1) first(B) intersection First(C) should be null otherwise grammar is not LL1. If First(B) contains epsilon then Follow(A) intersection First(C) should be null. Using this we can say grammar is LL(1) or not without constructing parsing table.
    An ∈ ∈ free LL(1) grammar is also SLR(1) and hence LALR(1) and LR(1) too.
    Since there is no conflict, the grammar is LL(1). We can construct a predictive parse table with no conflicts. This grammar also LR(0), SLR(1), CLR(1) and LALR(1).


  1. Consider the grammar shown below:
    S → i E t S S’/ a
    S → e S I ε
    E → b
    In the predictive parser table, M of this grammar, the entire M[S’, e] and M [S’,$] respectively are









  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    NA



  1. In a bottom-up evaluation of a syntax directed definition, inherited attributes can









  1. View Hint View Answer Discuss in Forum

    A Syntax Directed Definition (SDD) is called S Attributed if it has only synthesized attributes. L-Attributed Definitions contain both synthesized and inherited attributes but do not need to build a dependency graph to evaluate them.

    Correct Option: B

    A Syntax Directed Definition (SDD) is called S Attributed if it has only synthesized attributes. L-Attributed Definitions contain both synthesized and inherited attributes but do not need to build a dependency graph to evaluate them.