Home » Compiler Design » Compiler design miscellaneous » Question

Compiler design miscellaneous

  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. X = Y + Z
    2. t1 = Y + Z; X = t1
    3. t1 = Y; t2 = t1 + Z; X = t2
    4. t1 = Y; t2 = Z; t3 = t1 + t2 ; X = t3
Correct Option: B

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



Your comments will be displayed only after manual approval.