Retrieving academic index assets...
Makaut
HomePYQsTests
Pricing
Sign Up
Makaut

The premier academic archive for MAKAUT students, providing curated previous year questions, solutions, and official syllabus resources.

Get the Mobile App
GET IT ONGoogle Play
Download on theApp Store
Download from Indus App Store
Platform
  • Home
  • PYQs
  • Question Papers
  • Viva Questions
  • Important Questions
  • Syllabus
  • Academic Tools
  • Pricing
  • Blog
Guidelines
  • Disclaimer
  • Community Guidelines
Company
  • About
  • Contact
  • FAQ
Legal
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Cookie Policy
  • Subscription Policy
© 2026 MAKAUT Study Dev Hub. All rights reserved.
Platform version: v1.0.0
Viva Questions/PCC-CS501
Semester 5PCC-CS501

Compiler Design (PCC-CS501) Viva Questions and Answers

35 Questions•7 min read
Prepared from MAKAUT past-year question papers.
Practice Mode:All answers visible
Jump to Topic
Introduction to Compilers (3)Compiler Phases (1)Lexical Analysis (6)Syntax Analysis (2)Parsing (8)Intermediate Code Generation (3)Syntax-Directed Translation (4)Code Optimization (5)Code Generation (2)Formal Languages (1)

Introduction to Compilers

3 questions
Q1.EASY

What is a compiler and how is it different from an interpreter?

A compiler translates the entire source program into target code before execution, while an interpreter executes the source program line by line. Compilers generally produce faster executable code but require more memory and time for translation.
Q32.EASY

What is the difference between a compiler and an interpreter?

A compiler translates the whole program to machine code before execution, while an interpreter executes the source directly. Compilers are faster at runtime but slower to start; interpreters are more flexible.
Q33.EASY

What is a source-to-source translator?

A source-to-source translator converts a program from one high-level language to another. For example, converting C++ to C.

Compiler Phases

1 question
Q2.EASY

Name the phases of a compiler in order.

The phases are: lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, and code generation. Symbol table management and error handling are performed throughout.

Lexical Analysis

6 questions
Q3.EASY

What is the input to LEX?

The input to LEX is a set of regular expressions and associated actions written in a specification file. LEX uses these to generate a lexical analyzer (scanner) in C.
Q4.MEDIUM

Describe input buffering in a lexical analyzer.

Input buffering uses two pointers (lexeme begin and forward) over a buffer to scan characters efficiently. A common scheme uses two buffers that are refilled alternately to handle large input without frequent I/O.
Q5.MEDIUM

How does a lexical analyzer recognize a token?

It uses finite automata (DFA) built from regular expressions to match the longest prefix of the input that forms a lexeme. The matched lexeme is then classified into a token category.
Q6.EASY

What is the difference between a token, a lexeme, and a pattern?

A token is a category (e.g., identifier), a lexeme is the actual string matched (e.g., 'count'), and a pattern is the rule (e.g., letter followed by letters/digits) describing lexemes for a token.
Q25.EASY

What is the output of a lexical analyzer?

The output is a stream of tokens, each with a token name and optional attribute value (like an identifier's name). It also interacts with the symbol table.
Q34.MEDIUM

What is the number of tokens in printf("%d,%d",a,b);?

The tokens are: printf, (, "%d,%d", ,, a, ,, b, ), ; — total 10 tokens.

Syntax Analysis

2 questions
Q7.MEDIUM

If all operators are binary, when is a string of operands and operators a valid postfix expression?

It is valid if, when scanned left to right, the number of operands always exceeds the number of operators by at least one, and at the end the difference is exactly one.
Q8.MEDIUM

What is an ambiguous grammar? Give an example.

A grammar is ambiguous if some string has more than one parse tree. For example, G: S → aS | Sa | a is ambiguous because 'aa' can be derived in two ways.

Parsing

8 questions
Q9.MEDIUM

Why is a left-recursive grammar not suitable for predictive parsers?

Left recursion causes the parser to loop forever when trying to expand the leftmost non-terminal. Predictive parsers require left-factored, non-left-recursive grammars to decide productions using lookahead.
Q10.MEDIUM

Remove left recursion from E → E + T | T.

The transformed grammar is E → T E' and E' → + T E' | ε. This eliminates immediate left recursion and is suitable for LL(1) parsing.
Q26.EASY

What is YACC?

YACC (Yet Another Compiler-Compiler) is a parser generator that takes a grammar specification and produces a parser, typically in C. It is used with LEX for lexical analysis.
Q27.HARD

What is the difference between SLR, LR(1), and LALR parsers?

SLR uses FOLLOW sets for reductions, LR(1) uses full lookahead items, and LALR merges LR(1) states with common cores. LALR is more powerful than SLR and more practical than LR(1).
Q28.MEDIUM

What is a reduce/reduce conflict?

A reduce/reduce conflict occurs when a parser state has two or more reductions possible for the same lookahead. It happens in bottom-up parsing when the grammar is ambiguous or not LR.
Q29.EASY

What is the FIRST set of a grammar symbol?

FIRST(X) is the set of terminals that can begin strings derived from X. If X can derive ε, then ε is also in FIRST(X).
Q30.EASY

What is the FOLLOW set of a non-terminal?

FOLLOW(A) is the set of terminals that can appear immediately after A in some sentential form. It is used in LL(1) parsing and SLR parsing.
Q31.MEDIUM

What is a non-recursive predictive parser?

It is a table-driven parser that uses an explicit stack instead of recursion. It consults a parsing table based on the current non-terminal and lookahead to decide the production.

Intermediate Code Generation

3 questions
Q11.EASY

What is a basic block?

A basic block is a maximal sequence of consecutive three-address statements with a single entry point and a single exit point. Control enters only at the beginning and leaves only at the end.
Q12.EASY

What is three-address code? Give an example.

Three-address code is an intermediate representation where each instruction has at most one operator and three operands. For example, x = y + z is represented as t1 = y + z; x = t1.
Q13.MEDIUM

Convert y = (a + b) * c into postfix notation and three-address code.

Postfix: a b + c *. Three-address code: t1 = a + b; t2 = t1 * c; y = t2.

Syntax-Directed Translation

4 questions
Q14.EASY

What is a synthesized attribute?

A synthesized attribute's value at a parse tree node is computed from the attribute values of its children. It is used in S-attributed definitions and evaluated bottom-up.
Q15.MEDIUM

Compare S-attributed and L-attributed SDT.

S-attributed definitions use only synthesized attributes and are evaluated bottom-up. L-attributed definitions allow both synthesized and inherited attributes but restrict inherited attributes to depend only on left siblings and parent, enabling top-down evaluation.
Q16.EASY

What is an annotated parse tree?

An annotated parse tree shows the values of attributes at each node, typically for syntax-directed translation. It helps visualize how semantic rules compute values.
Q17.MEDIUM

What is a postfix SDT?

A postfix SDT is a syntax-directed translation scheme where semantic actions are placed at the end of productions. It is convenient for bottom-up parsing because actions execute after the right side is reduced.

Code Optimization

5 questions
Q18.EASY

What is code optimization? Name two loop optimizations.

Code optimization improves intermediate code to reduce execution time or space without changing semantics. Loop invariant code motion and loop unrolling are two loop optimizations.
Q19.MEDIUM

Is elimination of loop invariant computation a peephole optimization?

No, it is a loop optimization, not a peephole optimization. Peephole optimization works on a small sliding window of instructions.
Q20.EASY

What is constant folding?

Constant folding is the compile-time evaluation of constant expressions, e.g., replacing x = 2 * 3 with x = 6. It is a common peephole optimization.
Q21.MEDIUM

What is a DAG in compiler design?

A directed acyclic graph (DAG) is a compact representation of expressions that shows common subexpressions. It is used in optimization and can be converted back to three-address code.
Q24.EASY

What is a peephole optimization? Give an example.

Peephole optimization examines a small window of instructions to replace them with faster or shorter sequences. For example, removing redundant loads and stores like MOV R1, R1.

Code Generation

2 questions
Q22.MEDIUM

How many descriptors are used to track registers and addresses during code generation?

Two descriptors are used: a register descriptor tracks which values are in each register, and an address descriptor tracks where each variable's value is stored.
Q23.MEDIUM

What is garbage collection in compiler context?

Garbage collection is the automatic reclamation of memory that is no longer reachable by the program. It is part of runtime environment support, often used in languages like Java.

Formal Languages

1 question
Q35.HARD

What is the intersection of a regular language and a context-free language?

The intersection of a regular language and a context-free language is always context-free. This is because regular languages are closed under intersection with context-free languages.

Frequently Asked Viva Voce Questions

High-priority theoretical and lab evaluation questions typically tested by MAKAUT external examiners.

Related Course Resources

SYLLABUSCompiler Design Syllabus & Handouts
Open resource
PYQSemester 5 PYQ Papers
Open resource

On This Page

10 Units
Introduction to Compilers3
Compiler Phases1
Lexical Analysis6
Syntax Analysis2
Parsing8
Intermediate Code Generation3
Syntax-Directed Translation4
Code Optimization5
Code Generation2
Formal Languages1