Compiler design miscellaneous


Compiler design miscellaneous

  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.



  1. Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between n1 and n2 is









  1. View Hint View Answer Discuss in Forum

    SLR parser is less range of context free languages than LALR but still both n1 & n2 are same for SLR & LALR respectively. Hence (b) is correct option.

    Correct Option: B

    SLR parser is less range of context free languages than LALR but still both n1 & n2 are same for SLR & LALR respectively. Hence (b) is correct option.


  1. Which of the following suffices to convert an arbitrary CFG to an LL (1) grammar?









  1. View Hint View Answer Discuss in Forum

    Removing left recursion and factoring the grammar do not suffice to convert an arbitrary CFG to LL(1) grammar because: We have following these steps to convert an arbitrary CFG to LL(1) grammar: 1. Remove ambiguity (by taking care of precedence and associatively) 2. Remove Left Recursion (This will come when you remove ambiguity) 3. Make grammar deterministic by Left factoring (In case occur) To convert CFG to LL(1), which is top down parser. If the grammar is ambiguous, is left recursive and has left factoring, then, it is not a LL(1). For LL(1) all the three should be removed.

    Correct Option: D

    Removing left recursion and factoring the grammar do not suffice to convert an arbitrary CFG to LL(1) grammar because: We have following these steps to convert an arbitrary CFG to LL(1) grammar: 1. Remove ambiguity (by taking care of precedence and associatively) 2. Remove Left Recursion (This will come when you remove ambiguity) 3. Make grammar deterministic by Left factoring (In case occur) To convert CFG to LL(1), which is top down parser. If the grammar is ambiguous, is left recursive and has left factoring, then, it is not a LL(1). For LL(1) all the three should be removed.



  1. Consider the syntax directed definition shown below :

    Here, gen a function that generates the output code, and newtemp is a function that returns the name of a new temporary variable on every call. Assume that t1 ‘ s are the temporary variable names generated by newtemp. For the statement ‘X = Y + Z’, the 3 - address code sequence generated by this definition is









  1. View Hint View Answer Discuss in Forum

    The production E → E + E is used only one time and hence only one temporary variable is generated.

    Correct Option: B

    The production E → E + E is used only one time and hence only one temporary variable is generated.