CSC365 Compiler Design and Construction

Compiler Design and Construction TU Board 2081 question paper

12 questionsSit this paper (timed)

Tribhuvan University

Bachelor of Science in Computer Science and Information Technology

Semester 6 · TU Board 2081

Course Title: Compiler Design and Construction (CSC365)

Full Marks: 60Pass Marks: 24Time: 3 hours

Candidates are required to give their answers in their own words as far as practicable. The figures in the margin indicate full marks.

Group A

Attempt any TWO questions.(2 × 20 = 40)

  1. 1.

    Give an example of reduce-reduce conflict. Construct the SLR parsing table for the following grammar.

    E→ (L) | a
    L → L, E | E

    20
  2. 2.

    What are the significances of intermediate code? Differentiate between DAG and Syntax tree. Represent the instruction A = B + C − D * E + G using quadruple and triple.

    20
  3. 3.

    Illustrate the concept of backpatching with an example. Convert the regular expression a(a + b)a# to DFA.

    20

Group B

Attempt any TWO questions.(2 × 10 = 20)

  1. 4.

    Explain different phases of compiler in brief.

    10
  2. 5.

    What types of information are stored in a symbol table? Discuss the activation record.

    10
  3. 6.

    Compute the FIRST and FOLLOW of the non-terminals in the following grammar:
    S → (L) ∣ 1
    L → LS ∣∗S

    10
  4. 7.

    Write the code generation algorithm for the instruction a = b op c.

    10
  5. 8.

    Define core item. Compute the LR(1) item sets for the following grammar:
    S → AA
    A → aA ∣ b

    10
  6. 9.

    How do you represent recursion in an activation tree? Generate the three-address code for the following instruction:

    n = (a + b) * (c - d);
    for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
    x = n + i + j;
    }
    }

    10
  7. 10.

    What are the techniques for compiler optimization? Explain.

    10
  8. 11.

    Describe the synthesized attribute and inherited attribute with an example.

    10
  9. 12.

    What is a type expression? List the properties of LL(1) grammar.

    10

— The End —