0% found this document useful (0 votes)
63 views2 pages

Answer All Questions, Each Carries 3 Marks.: Ɛ Ambiguous? Justify Your Answer

This document contains questions from an exam on compiler design. It covers topics like regular definitions, tokens, lexemes and patterns, LL(1) grammars, ambiguity, bootstrapping, cross-compilers, grammar transformations, predictive parsing tables, recursive descent parsing, syntax directed definitions, FIRST and FOLLOW sets, operator precedence parsing, LR(0) parsing, shift-reduce conflicts, S-attributed and L-attributed definitions, bottom-up evaluation, syntax trees, triples, quadruples, static and dynamic allocation strategies, loop optimizations like code motion and induction variable elimination, basic block optimizations, code generation algorithms, and generating code sequences.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views2 pages

Answer All Questions, Each Carries 3 Marks.: Ɛ Ambiguous? Justify Your Answer

This document contains questions from an exam on compiler design. It covers topics like regular definitions, tokens, lexemes and patterns, LL(1) grammars, ambiguity, bootstrapping, cross-compilers, grammar transformations, predictive parsing tables, recursive descent parsing, syntax directed definitions, FIRST and FOLLOW sets, operator precedence parsing, LR(0) parsing, shift-reduce conflicts, S-attributed and L-attributed definitions, bottom-up evaluation, syntax trees, triples, quadruples, static and dynamic allocation strategies, loop optimizations like code motion and induction variable elimination, basic block optimizations, code generation algorithms, and generating code sequences.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

B B6815 Pages: 2

Reg No.:_______________ Name:__________________________


APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY
SIXTH SEMESTER B.TECH DEGREE EXAMINATION, APRIL 2018
Course Code: CS304
Course Name: COMPILER DESIGN (CS, IT)
Max. Marks: 100 Duration: 3 Hours

PART A
Answer all questions, each carries 3 marks. Marks
1 Draw the transition diagram for the regular definition, (3)
relop< | <= | = | <> | >= | >
2 With an example source language statement, explain tokens, lexemes and (3)
patterns.
3 Define LL( 1) grammars. (3)
4 Is the grammar SS(S)S/ Ɛ ambiguous? Justify your answer. (3)
PART B
Answer any two full questions, each carries 9 marks.
5 a) Apply bootstrapping to develop a compiler for a new high level language P on (3)
machine N.
b) Now I have a compiler for P on machine N. Apply bootstrapping to obtain a (4)
compiler for P on machine M.
c) Define cross-compilers. (2)
6 a)
Consider the following grammar
E E or T | T
T T and F |F
F not F | (E) | true | false
(2)
(i) Remove left recursion from the grammar. (4)
(ii) Construct a predictive parsing table.
(iii) Justify the statement “ The grammar is LL (1)”. (3)
7 a) Design a recursive descent parser for the grammar ScAd, Aab/ b (5)
b) For a source language statement a= b*c - 2, where a, b and c are float variables, (4)
* and – represents multiplication and subtraction on same data types, show the
input and output at each of the compiler phases.
PART C
Answer all questions, each carries 3 marks.
8 Compute the FIRST and FOLLOW for the following Grammar. (3)

Page 1 of 2
B B6815 Pages: 2

SBb/Cd BaB/Ɛ CcC/Ɛ


9 Demonstrate the identification of handles in operator precedence parsing? (3)
10 Design a Syntax Directed Definition for a Desk calculator that prints the result. (3)
11 Describe the type checking of functions. (3)
PART D
Answer any two full questions, each carries 9 marks.
12 a) Construct canonical LR(0) collection of items for the grammar below. (5)
SL = R
SR
L*R
L  id
RL
Also identify a shift reduce conflict in the LR(0) collection constructed above.
b) Define S-attributed and L-attributed definitions. Give an example each. (4)
13 a) Explain bottom- up evaluation of S- attributed definitions. (5)
b) With an SDD for a desk calculator, give the appropriate code to be executed at (4)
each reduction in the LR parser designed for the calculator. Also give the
annotated parse tree for the expression (3*5) –2.
14 a) Construct LALR parse table for the grammar S->CC,C->cC|d (9)
PART E
Answer any four full questions, each carries 10 marks.
15 a) Write syntax directed definitions to construct syntax tree and three address code (10)
for assignment statements.
16 a) Explain quadruples and triples with an example each. (5)
b) Construct the syntax tree and then draw the DAG for the statement (5)
e := (a*b) + (c-d) * (a*b)
17 a) Explain static allocation and heap allocation strategies. (10)
18 a) With an example each explain the following loop optimization techniques: (i) (10)
Code motion (ii) Induction variable elimination and (iii) strength reduction
19 a) Explain any two issues in the design of a code generator. (5)
b) Explain the optimization of basic blocks. (5)
20 a) Write the Code Generation Algorithm and explain the getreg function. (6)
b) Generate a code sequence for the assignment d=(a-b)+(a-c)+(a-c) (4)
****

Page 2 of 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy