(SEM VI) THEORY EXAMINATION 2018-19 COMPILER DESIGN

B.Tech General 0 downloads
₹29.00

SECTION A – Short Answer Notes (2 Marks Each)


1. Two Parts of Compilation

Compilation is broadly divided into analysis (front end) and synthesis (back end).
The analysis part checks the source program for errors and converts it into an intermediate form. It includes lexical analysis, syntax analysis, and semantic analysis.
The synthesis part takes this intermediate representation and generates optimized target machine code.


2. Viable Prefix

A viable prefix is a prefix of a right-sentential form that does not extend beyond the rightmost handle. It represents a valid state during shift-reduce parsing and helps detect syntax errors early.


3. Classification of Compilers

Compilers can be classified as single-pass and multi-pass, optimizing and non-optimizing, cross compilers, and source-to-source compilers. The classification depends on how many times the source code is scanned and the purpose of compilation.


4. Error Recovery Strategies in Lexical Analysis

Lexical analyzer handles errors using strategies such as panic mode recovery, error correction by deletion or insertion of characters, and replacement of invalid characters so that compilation can continue.


5. Dangling Else Problem

The dangling else problem arises in nested conditional statements where it is ambiguous to which if an else belongs. By convention, the else is associated with the nearest unmatched if.


6. Types of Intermediate Code Representation

Intermediate code can be represented using three-address code, syntax trees, DAGs, and postfix notation. These representations help in optimization and machine-independent analysis.


7. Peephole Optimization

Peephole optimization is a local optimization technique where a small window of target code instructions is examined to remove redundant or inefficient instructions without changing program meaning.


SECTION B – Descriptive Answers (7 Marks Each)


1. Quadruples, Triples and Indirect Triples

For the expression
(x+y)∗(y+z)+(x+y+z)(x+y)*(y+z)+(x+y+z)(x+y)∗(y+z)+(x+y+z)

Quadruples store operator, operands, and result explicitly, making them easy to modify.
Triples remove explicit result names and use positions instead.
Indirect triples add a pointer table to overcome reordering issues of triples.

(Explain with step-by-step table format in exam.)


2. Problems with Top-Down Parsing & FIRST/FOLLOW

Top-down parsing suffers from left recursion, backtracking, and ambiguity.
FIRST gives the set of terminals that begin strings derived from a non-terminal.
FOLLOW gives terminals that can appear immediately after a non-terminal.
Both are essential for constructing predictive parsers.


3. Shift Reduce Parsing

Shift-reduce parsing uses a stack and input buffer.
Operations include shift, reduce, accept, and error.
For given grammar and input (a,(a,a)), parsing proceeds by shifting symbols and reducing them using grammar rules until the start symbol is obtained.


4. Global Data Flow Analysis

Global data flow analysis collects information about the flow of data across basic blocks.
It helps detect dead code, common sub-expressions, and loop-invariant code, improving overall code optimization.


5. LR(0) Parsing Table

LR(0) parsing constructs item sets, builds DFA states, and generates ACTION and GOTO tables.
It is powerful but may face shift-reduce conflicts when grammar is not LR(0).


SECTION C – Long Answer Notes (7 Marks Each)


1. NFA to DFA Conversion

NFA is converted to DFA using subset construction method.
Each DFA state represents a set of NFA states.
After construction, DFA is minimized by merging equivalent states.


2. Parameter Passing Mechanisms

Common mechanisms include call by value, call by reference, call by result, call by value-result, and call by name.
Each differs in how data is transferred between calling and called functions.


3. DAG Representation

DAG represents expressions by eliminating redundant computations.
For a := b*-c + b*-c, common sub-expression b*-c is evaluated once and reused.


4. Static vs Dynamic Scope

In static scope, variable binding is resolved at compile time using lexical structure.
In dynamic scope, binding depends on runtime call sequence.
Static scope uses access links to reach non-local variables.


5. Loop Optimization Concepts

Loop unrolling reduces loop overhead            Loop jamming combines adjacent loops

Dominators identify control flow                     Viable prefix ensures parsing correctness

These techniques improve execution speed.


6. Syntax Directed Translation

Syntax-directed translation attaches semantic rules to grammar productions.
Annotated parse trees evaluate expressions like (4*7+1)*2 step by step using attributes.

7. Error Recovery in Operator Precedence Parsing

Error recovery detects invalid precedence relations and skips input symbols until a valid configuration is reached, allowing parsing to continue.

File Size
138.07 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

Spoken English Classes Near Sector 107 Gurugram (Dwarka Expressway) – Speak Fluently, Communicate Confidently Sector 107, Gurugram
Spoken English Classes Near By Defence Colony Improve Communication Skills, Confidence & Career Opportunities in 2026 Defence Colony, Delhi
Data Analytics Training Near Noida Sector 94 – Learn Data Skills and Build a High-Demand Career Noida
Singing / Vocal Training Near DLF Phase 2 – Professional Voice Training for All Age Groups DLF Phase 2, Gurugram
SEO Training Near Noida Sector 95 – Learn Search Engine Optimization and Build a Digital Career Noida
SEO Training Near Noida Sector 93 – Learn Search Engine Optimization and Build a Digital Career Sector 93, Noida
Maths Coaching Near By Dwarka Mor – Build Strong Concepts & Score Higher Dwarka Mor, Delhi
Spoken English Classes Near By Lajpat Nagar Build Fluency, Confidence & Professional Communication Skills in 2026 Lajpat Nagar, Delhi
Music Production (Laptop-Based) Classes Near Sector 143 Noida – Learn Professional Music Creation Sector 143, Noida
Painting Classes Near By Dwarka Mor – Discover the Artist Within You Dwarka Mor, Delhi
Yoga Classes Near By Defence Colony Experience Holistic Fitness, Mental Peace & Lifestyle Transformation in 2026 Defence Colony, Delhi
Diet & Nutrition Consultation Near Malibu Town – Personalized Guidance for a Healthy Lifestyle Malibu Town, Gurugram
Guitar Classes Near DLF Phase 1 Gurugram – Professional Music Training for Kids, Beginners & Adults DLF Phase I, Gurugram
Video Editing Classes Near Sector 82A Gurugram – Learn Professional Editing Skills Sector 82A, Gurugram
Spoken English Classes Near By Paschim Vihar Improve Fluency, Build Confidence & Unlock Better Career Opportunities in 2026 Paschim Vihar, Delhi
Competitive Exam Coaching Near Dwarka Mor Complete Preparation for Government & Entrance Exams with Expert Guidance Dwarka Mor, Delhi
Personality Development Classes Near Sector 56 Gurugram – Build Confidence, Communication & Professional Success Sector 56, Gurugram
Prenatal Yoga Training Near By Uttam Nagar – Safe & Guided Pregnancy Wellness Uttam Nagar, Delhi
Graphic Designing Classes Near Uttam Nagar – Turn Your Creativity into a Successful Career Uttam Nagar, Delhi
Guitar Classes Near Central Noida Sector 1 – Learn Guitar with Expert Trainers Noida
⭐ 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