(SEM VI) THEORY EXAMINATION 2024-25 COMPILAR DESIGN

B.Tech General 0 downloads
₹29.00

BCS602 – COMPILER DESIGN

Time: 3 Hours | Max Marks: 70


SECTION A – Short Answer Questions

(2 × 7 = 14 marks | Attempt ALL)
 Write definition + 1–2 crisp points


a. Phases vs Passes of a Compiler

Phases: Logical stages like lexical, syntax, semantic, code generation

Passes: Number of times source program is read               One pass may contain multiple phases.


b. Top-Down vs Bottom-Up Parsing

Top-DownBottom-Up
Starts from start symbolStarts from input
LL parsingLR parsing
SimpleMore powerful


c. Inherited vs Synthesized Attributes                  Synthesized: Flow bottom-up (from children to parent)

Inherited: Flow top-down (from parent to children)
Used in syntax-directed translation.


d. Role of Hash Table in Symbol Table                  Fast insertion & lookup

Stores identifiers, type, scope                               Reduces search time during compilation


e. Finite State Machine (FSM)                               FSM is a model with states, transitions, input alphabet.
Used in lexical analysis to recognize tokens.     (Design FSM with 4 states for even a’s & odd b’s in exam.)


f. Lexical vs Syntactic Structure

Lexical: Tokens, keywords, identifiers                   Syntactic: Grammar rules, parse trees
Lexical → Syntax analysis sequence.


g. Machine-Independent Code Optimization

Optimization that does not depend on target machine, e.g.:

Constant folding                                                    Common sub-expression elimination

Dead code elimination


SECTION B – Medium Answer Questions

(7 × 3 = 21 marks | Attempt ANY THREE)

Write stepwise explanation + diagram/example


a. Phases of Compilation (Very Important)              Lexical Analysis

Syntax Analysis                                                         Semantic Analysis

Intermediate Code Generation                                Code Optimization

Target Code Generation                                    

Explain outputs for:                                                   **a = (b + c)(b + c)2


b. Ambiguous Grammar Proof

Grammar:                                                                S → aSbS | bSaS | ε


Show two different parse trees / rightmost derivations
Confirms ambiguity.


c. Role of Symbol Table in Compiler Phases              Lexical: stores identifiers

Syntax: checks declarations                                       Semantic: type checking

Code generation: memory allocation


d. SLR Parsing Table Construction

Given grammar:                                                         S → Aa | bAc | Bc | bBa   A → d   B → d 


Steps:

Augmented grammar                                                LR(0) items

ACTION & GOTO table                                              Check conflicts (Shift/Reduce)


e. Semantic Errors & Detection

Examples:                                                                  Type mismatch

Undeclared variable                                                  Wrong number of arguments

Detected during semantic analysis using symbol table.


SECTION C – Attempt ANY ONE

(7 marks)

a. LL(1) Parsing Table Construction

Grammar:                                                                   S → aB | aC | Sd | Se   B → bBc | f   C → g 


Steps:                                                                         Remove left recursion

Compute FIRST & FOLLOW                                       Construct table

Check conflicts


b. Design Issues in Code Generation                        Instruction selection

Register allocation                                                    Memory addressing

Target machine architecture                                     Directly affects compiler performance.

File Size
122.34 KB
Uploader
SuGanta International
⭐ Elite Educators Network

Meet Our Exceptional Teachers

Discover passionate educators who inspire, motivate, and transform learning experiences with their expertise and dedication

KISHAN KUMAR DUBEY

KISHAN KUMAR DUBEY

Sant Ravidas Nagar Bhadohi, Uttar Pradesh , Babusarai Market , 221314
5 Years
Years
₹10000+
Monthly
₹201-300
Per Hour

This is Kishan Kumar Dubey. I have done my schooling from CBSE, graduation from CSJMU, post graduati...

Swethavyas bakka

Swethavyas bakka

Hyderabad, Telangana , 500044
10 Years
Years
₹10000+
Monthly
₹501-600
Per Hour

I have 10+ years of experience in teaching maths physics and chemistry for 10th 11th 12th and interm...

Vijaya Lakshmi

Vijaya Lakshmi

Hyderabad, Telangana , New Nallakunta , 500044
30+ Years
Years
₹9001-10000
Monthly
₹501-600
Per Hour

I am an experienced teacher ,worked with many reputed institutions Mount Carmel Convent , Chandrapu...

Shifna sherin F

Shifna sherin F

Gudalur, Tamilnadu , Gudalur , 643212
5 Years
Years
₹6001-7000
Monthly
₹401-500
Per Hour

Hi, I’m Shifna Sherin! I believe that every student has the potential to excel in Math with the righ...

Divyank Gautam

Divyank Gautam

Pune, Maharashtra , Kothrud , 411052
3 Years
Years
Not Specified
Monthly
Not Specified
Per Hour

An IIT graduate having 8 years of experience teaching Maths. Passionate to understand student proble...

Explore Tutors In Your Location

Discover expert tutors in popular areas across India

French Language Classes Near By Uttam Nagar – Learn French with Confidence Uttam Nagar, Delhi
Zumba Classes Near Sector 131 Greater Noida – Enjoy Dance Fitness and Stay Healthy Noida
Spoken English Classes Near By Defence Colony Improve Communication Skills, Confidence & Career Opportunities in 2026 Defence Colony, Delhi
Zumba Classes Near Palam Vihar Extension – Dance Your Way to Fitness New Palam Vihar, Gurugram
Public Speaking Training Near Uttam Nagar – Speak with Confidence & Impact Uttam Nagar, Delhi
Prenatal Yoga Training Near Uppal Southend, Gurugram – A Calm & Healthy Pregnancy Journey Uppal Southend, Gurugram
Meditation Coaching Near By Nangloi – Find Inner Peace & Mental Clarity Nangloi, Delhi
Violin Classes Near DLF Phase 5 – Learn, Grow & Perform with Confidence DLF Phase V, Gurugram
Photography Basics Classes Near Sector 82 Gurugram – Learn, Click & Create H Block Sector 82, Gurugram
Harmonium Classes Near Sushant Lok Phase 1 – Learn Classical Music with Confidence Sushant Lok Phase 1, Gurugram
Guitar Classes Near Central Noida Sector 10 – Learn Guitar with Expert Trainers A Block Sector 10, Noida
Spoken English Classes Near By Tilak Nagar Improve Fluency, Build Confidence & Unlock Career Opportunities in 2026 Tilak Nagar, Delhi
Singing / Vocal Training Near Sector 18 Market Area Noida – Learn Music with Professional Vocal Trainers Noida Sector 18, Noida
Yoga Classes (Home or Online) Near Sushant Lok Phase 3 – Transform Your Health Naturally Phase 3 Sushant Lok, Gurugram
App Development Classes Near Uttam Nagar – Build Android & iOS Apps Uttam Nagar, Delhi
Candle Making Classes Near Sector 83 Gurugram – Learn the Art of Handmade Candles Gurugram
Piano Classes Near Tilak Nagar – Learn, Play & Master Music with Confidenc Tilak Nagar, Delhi
Guitar Classes Near Chhatarpur – Professional Guitar Training in South Delhi Chhatarpur, Delhi
Computer Classes Near Sector 90 Gurugram – Build Digital Skills for a Smarter Future Sector 90 Road, Gurugram
Violin Classes Near DLF Phase 5 – Learn Classical & Modern Violin from Expert Teachers DLF Phase V, Gurugram
⭐ Premium Institute Network

Discover Elite Educational Institutes

Connect with top-tier educational institutions offering world-class learning experiences, expert faculty, and innovative teaching methodologies

Réussi Academy of languages

sugandha mishra

Réussi Academy of languages
Madhya pradesh, Indore, G...

Details

Coaching Center
Private
Est. 2021-Present

Sugandha Mishra is the Founder Director of Réussi Academy of Languages, a premie...

IGS Institute

Pranav Shivhare

IGS Institute
Uttar Pradesh, Noida, Sec...

Details

Coaching Center
Private
Est. 2011-2020

Institute For Government Services

Krishna home tutor

Krishna Home tutor

Krishna home tutor
New Delhi, New Delhi, 110...

Details

School
Private
Est. 2001-2010

Krishna home tutor provide tutors for all subjects & classes since 2001

Edustunt Tuition Centre

Lakhwinder Singh

Edustunt Tuition Centre
Punjab, Hoshiarpur, 14453...

Details

Coaching Center
Private
Est. 2021-Present
Great success tuition & tutor

Ginni Sahdev

Great success tuition & tutor
Delhi, Delhi, Raja park,...

Details

Coaching Center
Private
Est. 2011-2020