Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Past Questions on Compiler design from basics to advanced, Exercises of Compiler Design

Past Questions on Compiler design from basics to advanced

Typology: Exercises

2024/2025

Uploaded on 06/12/2025

qais-shittu
qais-shittu 🇬🇧

2 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Compiler Design
Question Bank
UNIT 1
1. What is Compiler? Design the Analysis and Synthesis Model of Compiler.
2. Write down the five properties of compiler.
3. What is translator? Write down the steps to execute a program.
4. Discuss all the phases of compiler with a with a diagram.
5. Write a short note on:
a. YACC
b. Pass
c. Bootstrapping
d. LEX Compiler
e. Tokens, Patterns and Lexemes
6. Write the steps to convert Non-Deterministic Finite Automata (NDFA) into Deterministic Finite
Automata (DFA).
7. Let M=({q0,q1}, {0,1}, , q0, {q1}).
Be NFA where (q0,0)={q0,q1}, (q1,1) = {q1}
(q1, 0)=, (q1, 1)={q0, q1}
Construct its equivalent DFA.
8. Convert the given NFA to DFA:
Input/State
0
1
q0
{q0, q1}
q0
q1
q2
q1
q2
q3
q3
q3 (final state)
(null character)
q2
9. What is Regular Expression? Write the regular expression for:
a. R=R1+R2 (Union operation)
b. R=R1.R2 (concatenation Operation)
c. R=R1* (Kleen Clouser)
d. R=R+ (Positive Clouser)
e. Write a regular expression for a language containing strings which end with “abb” over
Ʃ = {a,b}.
f. Construct a regular expression for the language containing all strings having any
number of a’s and b’s except the null string.
10. Construct Deterministic Finite Automata to accept the regular expression :
(0+1)* (00+11) (0+1)*
pf3
pf4
pf5

Partial preview of the text

Download Past Questions on Compiler design from basics to advanced and more Exercises Compiler Design in PDF only on Docsity!

Compiler Design

Question Bank

UNIT 1

  1. What is Compiler? Design the Analysis and Synthesis Model of Compiler.
  2. Write down the five properties of compiler.
  3. What is translator? Write down the steps to execute a program.
  4. Discuss all the phases of compiler with a with a diagram.
  5. Write a short note on: a. YACC b. Pass c. Bootstrapping d. LEX Compiler e. Tokens, Patterns and Lexemes
  6. Write the steps to convert Non-Deterministic Finite Automata (NDFA) into Deterministic Finite Automata (DFA).
  7. Let M=({q0,q1}, {0,1}, ᵟ , q0, {q1}). Be NFA where ᵟ (q0,0)={q0,q1}, ᵟ (q1,1) = {q1} ᵟ (q1, 0)=ᵩ, ᵟ (q1, 1)={q0, q1} Construct its equivalent DFA.
  8. Convert the given NFA to DFA: Input/State 0 1  q0 {q0, q1} q q1 q2 q q2 q3 q q3 (final state) ᵩ (null character) q
  9. What is Regular Expression? Write the regular expression for: a. R=R1+R2 (Union operation) b. R=R1.R2 (concatenation Operation) c. R=R1* (Kleen Clouser) d. R=R+ (Positive Clouser) e. Write a regular expression for a language containing strings which end with “abb” over Ʃ = {a,b}. f. Construct a regular expression for the language containing all strings having any number of a’s and b’s except the null string.
  10. Construct Deterministic Finite Automata to accept the regular expression : (0+1)* (00+11) (0+1)*
  1. Derivation and Parse Tree: a. Let G be a Context Free Grammar for which the production Rules are given below:

S -> aB|bA

A -> a|aS|bAA

B -> b|bS|aBB

Drive the string aaabbabbba using the above grammar (using Left Most Derivation and Right most Derivation).

UNIT 2

1. Explain the parsing techniques with a hierarchical diagram. 2. What are the problems associated with Top Down Parsing? 3. Write the production rules to eliminate the left recursion and left factoring problems. 4. Consider the following Grammar:

A-> ABd|Aa|a

B-> Be|b

Remove left recursion.

  1. Do left factoring in the following grammar:

A-> aAB|aA|a

B-> bB|b

  1. Write a short note on: a. Ambiguity (with example) b. Recursive Descent Parser c. Predictive LL(1) parser (working) d. Handle pruning e. Operator Precedence Parser
  2. Write Rules to construct FIRST Function and FOLLOW Function.
  3. Consider Grammar:

E-> E+T|T

T-> T*F|F

F-> (E)|id

  1. What is LALR parser? Construct the set of LR(1) items for this grammar:

S-> CC

C-> aC

C->d

  1. Show the following grammar

S->Aa|bAc|Bc|bBa

A->d

B->d

Is LR(1) but not LALR(1).

  1. Write the comparison among SLR Parser, LALR parser and Canonical LR Parser.

UNIT 3

  1. What is syntax directed translation (SDD)?
  2. Write short note on: a. Synthesized attributes b. Inherited attributes c. Dependency graph d. Evaluation order e. Directed Acyclic Graph (DAG)
  3. Draw the syntax tree and DAG for the following expression:

(ab)+(c-d)(a*b)+b

  1. Differentiate between synthesized translation and inherited translation.
  2. What is intermediate code and write the two benefits of intermediate code generation.
  3. Write the short note on: a. Abstract syntax tree b. Polish notation c. Three address code d. Backpatching
  4. Construct syntax tree and postfix notation for the following expression:

(a+(b*c)^d-e/(f+g)

  1. Write quadruples, triples and indirect triples for the expression:

-(a*b)+(c+d)-(a+b+c+d)

  1. Write the three address statement with example for: a. Assignment b. Unconditional jump (goto) c. Array statement (2D and 3D) d. Boolean expression e. If-then-else statement f. While, do-while statement g. Switch case statement

UNIT 4

  1. Write the definition of symbol table and procedure to store the names in symbol table.
  2. What are the data structures used in symbol table?
  3. What are the limitations of stack allocation?
  4. Write two important points about heap management.
  5. Write the comparison among Static allocation, Stack allocation and Heap Allocation with their merits and limitations.
  6. What is activation record? Write the various fields of Activation Record.
  7. What are the functions of error handler?
  8. Write a short note on Error Detection and Recovery.
  9. Classify the errors and discuss the errors in each phase of Compiler.

UNIT 5

  1. What are the properties of code generation phase? Also explain the Design Issues of this phase.
  2. What are basic blocks? Write the algorithm for partitioning into Blocks.
  3. Write a short note on: a. Flow graph (with example) b. Dominators c. Natural loops d. Inner loops e. Reducible flow graphs