TRIBHUVAN UNIVERSITY
INSTITUTE OF SCIENCE AND TECHNOLOGY
2080 B.S.
Candidates are required to give their answers in their own words as far as practicable.
Group A
Long Answer QuestionsAttempt any Two questions.
- 1Differentiate 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$
- 2How 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.
- 3Construct 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 QuestionsAttempt any Eight questions.
- 4Why code optimization is needed? Describe any two techniques for loop optimization.
- 5What is three-address code? How high level code is converted to three-address code? Illustrate with an example.
- 6What is activation tree? Define type checking system with examples.
- 7What are the advantages of intermediate code? What types of information are provided by symbol table?
- 8What is annotated parse tree? Define S-attributed grammar with an example.
- 9Describe about syntax directed translation with an example.
- 10Given 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)

- 11How do you recognize basic block? Discuss about the factors that affect code generator.
- 12Find 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$