Compiler Design and Construction (CSC376) 2080 BS Past Questions & Solutions

Tribhuvan University (TU) 2080 BS board exam question paper with verified step-by-step solutions for BSc CSIT Sixth Semester.

TRIBHUVAN UNIVERSITY

INSTITUTE OF SCIENCE AND TECHNOLOGY

2080 B.S.

Bachelor Level: B.Sc. CSIT

Semester: Sixth Semester

Subject: Compiler Design and Construction (CSC376)

Full Marks: 60 / 80

Pass Marks: 24 / 32

Candidates are required to give their answers in their own words as far as practicable.

Group A

Long Answer Questions

Attempt any Two questions.

  1. 1
    Differentiate between one pass and multi pass compiler. Construct the $LL(1)$ parsing table for the following grammar. $S \rightarrow ABCD$ $A \rightarrow a | \epsilon$ $B \rightarrow b$ $C \rightarrow 0 | \epsilon$ $D \rightarrow d | e$
  2. 2
    How does Lexical Analyzer recognize a token? Give an example to make it clear. Convert the regular expression $a(a+b)(b+c)^*a\#$ to DFA.
  3. 3
    Construct the $LR(1)$ parsing table for the following grammar. $S \rightarrow AaAb$ $S \rightarrow BbBa$ $A \rightarrow \epsilon$ $B \rightarrow \epsilon$

Group B

Short Answer Questions

Attempt any Eight questions.

  1. 4
    Why code optimization is needed? Describe any two techniques for loop optimization.
  2. 5
    What is three-address code? How high level code is converted to three-address code? Illustrate with an example.
  3. 6
    What is activation tree? Define type checking system with examples.
  4. 7
    What are the advantages of intermediate code? What types of information are provided by symbol table?
  5. 8
    What is annotated parse tree? Define S-attributed grammar with an example.
  6. 9
    Describe about syntax directed translation with an example.
  7. 10
    Given the following grammar with SLR parsing table, test whether the string $\text{"int (int + int)"}$ will be accepted or rejected. $E \rightarrow T + E$ (1) $E \rightarrow T$ (2) $T \rightarrow int * T$ (3) $T \rightarrow int$ (4) $T \rightarrow (E)$ (5)
    Compiler Design and Construction 2080 Question 10
  8. 11
    How do you recognize basic block? Discuss about the factors that affect code generator.
  9. 12
    Find the FIRST and FOLLOW of all the non terminals in following grammar. $S \rightarrow aAbCD | \epsilon$ $A \rightarrow SD | \$$ $C \rightarrow Sa$ $D \rightarrow aBD | \epsilon$
Compiler Design and Construction (CSC376) 2080 BS Past Questions | BSc CSIT 6th Sem