Compiler Design 2025 — MAKAUT · PCC-CS-501 · Mid Sem PYQ with solutions

  • Solved
  • Verified

Maulana Abul Kalam Azad University of Technology

Solutions

28 answers across 3 groups

Try each question first, then open it to check your answer.

Group AVery Short Answer Type Question · answer any 10 · 1 mark each

  1. I

    What is postfix SDT?

    Free sample

    Answer: A Syntax-Directed Translation (SDT) where all the embedded semantic actions are placed exclusively at the extreme right end of the production rules.

  2. II

    What is equivalence of type expression?

  3. III

    The actual parameters are not used by the calling procedure. (true/false)

  4. IV

    "goto L" is an unconditional jump(to L) three address instruction.(true/false)

  5. V

    A basic block is a sequence of consecutive statements with single entry/single exit. (true/false)

  6. VI

    Flex is a lexical analyzer generator tool. (True/False)

  7. VII

    Write the name of translator that translates assembly code to relocatable machine code.

  8. VIII

    12_Name is a lexeme of pattern identifier in C language. (True/False)

  9. IX

    Write the rule for converting left recursive grammar to right recursive grammar.

  10. X

    What is Annotated -parse tree?

  11. XI

    Reduce/Reduce conflict happens during bottom up parsing. (True/False)

  12. XII

    How lexical analyzer recognize a token?

Group BShort Answer Type Question · answer any 3 · 5 marks each

  1. 2

    Write the difference between synthesized and inherited attributes with examples.

  2. 3

    Describe the purpose of two pointers of Buffer Pairs in Lexical Analyzer.

  3. 4

    Convert the DAG into Three address code.

    TEXT
          *
         / \
        +---+
       / \   \
      a   b   c
    
    Show answer to question 4
  4. 5

    Consider the postfix SDT: Here expr, expr_1 both are same, and for differentiate between left expr and right expr, we use expr_1 in right. expr →\rightarrow expr_1 + term { print('+') } expr →\rightarrow expr_1 - term { print('-') } expr →\rightarrow term term →\rightarrow 0 { print('0') } term →\rightarrow 1 { print('1') } ...................... term →\rightarrow 9 { print('9') } Draw the parse tree with action embedded for the expression 9 + 4 - 3.

  5. 6

    Convert the C code into three address instruction. while( A[i] >= v ){ i = i + 1; } where array elements are integers of 4 bytes in sized.

Group CLong Answer Type Question · answer any 3 · 15 marks each

  1. 7(a)

    Suppose ϵ\epsilon-closure(q) is a set of states which are reachable from q with zero or more ϵ\epsilon-moves, where q is a state in NFA. You are given a Regular Expression R = (b|a)*baa and the set of input symbols is {a,b}∪\cup{ ϵ\epsilon }. Convert this Regular Expression R to NFA N.

    3 marks
  2. 7(b)

    Convert this NFA N to DFA D using the definition of ϵ\epsilon-closure(q).

    7 marks
  3. 7(c)

    Convert this DFA D to Minimal DFA.

    5 marks
  4. 8(a)

    Suppose you have given a grammar of certain kind of statements and first & follow sets: A →\rightarrow B A' ; A' →\rightarrow + B A' | ϵ\epsilon ; B →\rightarrow C B' ; B' →\rightarrow * C B' | ϵ\epsilon ; C →\rightarrow ( A ) | id

    Non-terminalsFirst setsFollow sets
    A(, id), #
    A'+, ϵ\epsilon), #
    B(, id+, ), #
    B'*, ϵ\epsilon+, ), #
    C(, id+, *, ), #

    Where # is an end marker representing the end of input string. Build the predicting parsing table for the above grammar.

    Show answer to question 8(a)5 marks
  5. 8(b)

    Consider a new set for error recovery of predicting parsing, called synchronizing set of non-terminal A, is a set where each symbol of synchronizing set of non-terminal A is taken from follow(A) set. i.e synchronizing(C) = follow(C) = {+, *, ), #}. Instead of writing "error" in M[A, a] in parsing table, you use "syn" in that cell if a belongs to follow(A). Example: If M[ A, ) ] = "error" in table M, then you use "syn" in M[ A, ) ] cell of M, since ")" belongs to follow(A). The solution of (b) can be obtained from the following rules given below:

    • i) If the parser looks up entry M[ A, a ] and finds that is "error", then the input symbol a is skipped.
    • ii) If the entry is "sync", then it pops the non-terminal A from the stack to continue parsing, if A is the top of the STACK.
    • iii) If a token on top of the STACK does not match the input symbol, then you pop the token and resume parsing. Build an error correcting non-recursive version of predicting parsing table for the above grammar.
    Show answer to question 8(b)5 marks
  6. 8(c)

    From the solution of (b), show the behavior of your parser on the following input:

    Sl noSTACKINPUTBehavior/Action
    1.#A)id * + id#............
    2.....................................
    Show answer to question 8(c)5 marks
  7. 9

    Consider the grammar with productions: S →\rightarrow A a | b A c | d c | b d a ; A →\rightarrow d Prove that the above grammar is CLR(1) but not SLR(1) by building the parsing table.

  8. 10(a)

    Suppose you have been given the three address code of Quick Sort Algorithm

    Three address code for Quick Sort
    1 i := m-111 t5 := a[t4]21 a[t10] := x
    2 j := n12 if t5 > v goto (9)22 goto (5)
    3 t1 := 4*n13 if i >= j goto (23)23 t11 := 4* i
    4 v := a[t1]14 t6 := 4*i24 x := a[t11]
    5 i := i+115 x := a[t6]25 t12 := 4*i
    6 t2 := 4*i16 t7 := 4*i26 t13 := 4*n
    7 t3 := a[t2]17 t8 := 4*j27 t14 := a[t13]
    8 if t3 < v goto (5)18 t9 := a[t8]28 a[t12] := t14
    9 j := j-119 a[t7] := t929 t15 := 4*n
    10 t4 := 4*j20 t10 := 4*j30 a[t15] := x

    Find the leader codes and basic blocks including three address code of the above code.

    Show answer to question 10(a)10 marks
  9. 10(b)

    Build the flow graph for above code.

    5 marks
  10. 11(a)

    Describe in brief about the cousin of Compiler.

    5 marks
  11. 11(b)

    Describe the operation of different phases of Compiler with suitable example.

    10 marks

About this paper

The MAKAUT Compiler Design (PCC-CS-501) 2025 Mid Sem previous year question paper, set in semester 5. Download the verified PDF or read it online, then check your answers against the worked solutions above.

Common paper for 2 branches

Every branch listed gets the same questions. Pick a branch to see its other papers.

Why solve Compiler Design PYQs?

Frequently asked questions

5 questions

What is the subject code for Compiler Design?

PCC-CS-501 is the MAKAUT subject code for Compiler Design.

Which exam is this Compiler Design question paper from?

The MAKAUT 2025 Mid Sem exam, semester 5. A student shared it, and it was checked before publishing.

Which branches is this Compiler Design paper for?

It's a common paper for 2 B.Tech branches: Computer Science and Engineering and Information Technology. Every branch gets the same questions.

Where can I find more PCC-CS-501 question papers?

On the Compiler Design subject page, which collects every year's papers along with notes and the syllabus.

Are there solutions for this paper?

Yes. Every question has a worked answer on this page, grouped like the paper. The first answer is free to read; sign in (it's free) to unlock the rest.

Have notes or the answer key for Compiler Design?

Share it and help the next batch of students.