0% found this document useful (0 votes)
22 views31 pages

CE 5502

This document outlines the assessment tests for the Compiler Engineering course at Anna University, detailing the structure, questions, and marks distribution for various parts of the exam. It includes topics such as lexical analysis, parsing, compiler construction tools, and regular expressions. The assessment is divided into multiple parts with specific questions aimed at evaluating students' understanding and application of compiler engineering concepts.

Uploaded by

vignesh74364
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)
22 views31 pages

CE 5502

This document outlines the assessment tests for the Compiler Engineering course at Anna University, detailing the structure, questions, and marks distribution for various parts of the exam. It includes topics such as lexical analysis, parsing, compiler construction tools, and regular expressions. The assessment is divided into multiple parts with specific questions aimed at evaluating students' understanding and application of compiler engineering concepts.

Uploaded by

vignesh74364
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/ 31

Register

no:

FACULTY OF INFORMATION & COMMUNICATION ENGINEERING, ANNA UNIVERSITY CEG CAMPUS


DEPARTMENT OF INFORMATION SCIENCE AND TECHNOLOGY
Assessment Test – I
Academic year: 2021 (Odd Semester)
Regulation: 2019
Program: B.Tech (Information Technology) Year / SEM: III year / V sem
Max. Marks: 30 Duration: 1 hr
Date of Exam: 22/10/2021 Staff Name: Dr. M.Vijayalakshmi
& Dr.Abirami Murugappan

Course Code and Title: IT5502 Compiler Engineering

Part A (10 Marks)

Q. Question Course Blooms Marks


No outcome Taxonomy
1. For the block structured code given below, indicate the values assigned CO1 L(1,2) 2
to w, x, y and z
int w, x, y, z;
int i = 4; int j = 5;
{
Int j = 7;
i = 6; w = I +j;
}
x = i + j;
{
int i = 8;
y = i + j;
}
z = i + j;
2. a) Find the Regular Expression corresponding to given statement, subset CO1 L(3,3) 2
of {a, b}*. The Language of all strings containing at least one ‘a’ and at
most two ‘b’.
b) Describe the language denoted by the following regular expression:
(0|1)* (0|1)* 1 (0|1)(0|1)(0|1)

3. What are Buffer pairs and what is the use of Sentinels in it? CO1 L(2,1) 2
4. Identify the lexemes that make up the tokens in the following program CO1 L(4,2) 2
segment. Indicate the corresponding token and pattern.

int num = 56;


if(num % 2 == 0)
printf("%d is even.", num);
else
printf("%d is odd.", num);

5. If L₁ = { a, ba, aa, ab } and L₂ = { a, bb }, What is 2

1) L₁L₂

2) L₁|L₂

3) L22

4) L2*
Part B (40 Marks)
Q. Question Course Blooms Marks
No outcome Taxonomy
6. Consider the following regular expression CO1, CO6 L(4,3) 15
(a|b)*ab(a|b)
1) Construct NFA
2) Apply subset construction method to convert into DFA
3) Minimize the DFA.

7. A strong password is a string that contains CO1, CO6 L(3,2) 5


At least 8 characters (and up to 20 characters)
At least 3 of the following: uppercase, lowercase, numeric, or
special characters.
The allowed special characters are ~ ! @ # $ % [no spaces
allowed!]

a) Give the regular definitions for the above mentioned strings.


b) Draw the state transition diagram

All the Best!!!!


Roll No.
DEPARTMENT OF INFORMATION SCIENCE AND TECHNOLOGY
ANNAUNIVERSITY, CHENNAI
INTERNAL ASSESSMENT TEST I
INFORMATION TECHNOLOGY
Semester -V-July-Nov 2023
IT 5502 Compiler Engineering
(Regulation 2019)
Date: 21-09-2023
Time: 1 1/2 hrs
Max.Marks: 50
CO 1 Understand the concept of lexical analvsis and construction of deterministic and
non- deterministic automata.
CO 2 Understand the concept of parsing and
CO3 construction of
parser.
Develop an Intermediate Code generator.
CO 4 Study programming language design, target machine design and run time
environment of compilers.
CO5 Study about the compiler construction tools.
CO6 Obtain knowledge to construct a prototype compiler for asubset of a
programming language.
BL- Bloom's Taxonomy Levels
(L1- Remembering, L2 - Understanding, L3 - Applying, L4 - Analysing, L5 - Evaluating, L6 -
Creating)
PART- A(7x2 = 14 Marks)
(Answer all Questions)
Q. No
1
Questions Marks CO BL
Differentiate the terms Compiler and Interpreter. 2 CO1 L1
2 Find the regular expression for
one 'a' and one 'b' at the middlethe language consisting of
of the string, zero or moreatleast
2 CO1
followed'by one or more b's at the beginning of the string anda'szero
or more b's followed by a at the end of
the
3 If LË ={0, 1, 00, 11, 01 }and L ={0, 11},string.
What is CO1 L2
LLz
LIJLz
L2*
0V. L2*

Write down the language denoted by the regular


a(a |b') abb
expression: 2 CO1 L2

5 Write about any four compiler construction tools. 2 CO1


6 L1
Indicate the values assigned to w,x,y,z in the following code: 2 CO1 L2
int w,x,y,z,
int i=4; int j=5;
int j=7;
i=6;
w= itj;
x=i+j;
int i=8;
y=i+j.
z= itj
sat of charactorm
7 Write character classes for the following case followed by last ten CO1 12
i) The first twelve letters in upper
letters of lower case.
diaits
Lower case consonants followed by

PART- B(2x 12= 24 Marks)


(Restrict to amaximum of 2 subdivisions)
Questions Marks CO BL
Q. No
Compiler and, write down the 12 COG L2
8 (a) Explain about the phases of aexpression res=a*b-c/d+4-e
output of each phase for the
OR
expression is (0+1)-s(g+1) Co1 L3
8(b) () Construct an automata for the regular
ianguages? Write down the
0(0+t)", What are its accepting language is accepted by the
algorithm tocheck whether the
automata or not. CO1 L2
of Sentinelsin it in detail.
(0)Write about Buffer Pairs and the usage
8 CO1 L3
game has to be framed using the
9 (a) )|User name for aparticular
following rulés:
alphabet.
First letter'should be necessarily an upper case
atleast with the last
User name should consist of four alphabets the
letter ásalower case followed by 3 digits and any one of
specialcharacters such as @#$ %

a) Give the regular definitions for the above mentioned


strings.
b) Draw the state transition diagram for the unsigned numbers
CO1 L3
i) ldentify the lexeme that make up the tokens in the following
program segment. Indicate the corresponding token and pattern.
int compute (int a, int b)
int c;
for (i=0; i<10; | ++)
{
if (a>b) C=a tb;
else C= a- b;
if (c>100) break;
return c,

OR
9(b) Construct epsilon NFA for the following regular expression and 12 CO1 L3
apply subset construction method to convert into DFA:
(a<b)*ab*abb*
Alsominimize the states of DFA Dusing suitable algorithm.

PART- C(1x 12 =12 Marks)


(Q.No.10 iscompulsory)
Q. No Questions Marks CO BL
10 Construct DFA for the following regular expression without
constructing NFA: 12 CO1 L3
(a< ¬)* ab (a|b)' #
Roll No.
DEPARTMENT OF INFORMATION SCIENCE AND TECHNOLOGY
ANNAUNIVERsITY, CHENNAI
INTERNAL ASSESSMENT TEST I
INFORMATION TECHNOLOGY
Semester- y - July-Nov2023
IT 6502 Compiler Engineering
(Regulation 2019)
Date: 20-11-2023
Time: 1 1/2 hrs Max.Marks: 50
CO 1
Understand the concept of lexical analvsis and construction of deterministic and
non- deterministic automata.
CO 2 Understand the concept of parsing and construction of parser.
CO3 Develop an Intermediate Code generator.
CO 4
Study programming lnguage design, target machine design and run time
environment of compilers.
CO5 Study about the compiler construction tools.
CO 6 Obtain knowledge to construct a prototype compiler for a subset of a
progran.minglanguage.
BL- Bloom's Taxonomy Levels
(L1 - Remembering, L2 -Understanding, L3 - Applying, L4 - Analysing, L5 - Evaluating, L6 - Creating)

PART- A(7 x2=14 Marks)


(Answer alQuestions)
Q. No Questions Marks CO BL
ldentify whether the following grammar is LL(1) or not: CO2 L2
S-> A|B
A-> aaA<[
B-> abB|b
Left Factor the following grammar and eliminate the Left 2 CO2 L3
Recursion:
rexpr -> rexpr + rterm rterm
rterm -> term rfactor rfactor
rfactor -> rfactor *|rprimary
rprimary -> a|b
Consider the context-free grammar: Show howthe 2 CO2 L3
string aata* can be generated by this grammar using derivation
and parse tree method. What language does this grammar
generate?
S >SS+|SS*|a
Differentiate L-attributed and S-attributed definition 2 CO3 L1

Construct a DAG for the expression : 2 CO3 L2


atb+(btt(a+b*atatbta+)
Write down the pseudocode for widening type of conversion. CO3 L1
Translate the arithmeticexpression t( b*d)íinto Quadruples and 2 CO3 L2

Indirect Triples.
o--)
PART- B (2x 12 = 24 Marks)

(Restrict to amaximun of 2subdivisions) b


Q. No Questions Marks CO BL

Devise predictive parser and show the parsing table for the 12 CO2 L3
following grammar:
S-> b|(R)
T-> S, T|S
R-> T
Check whether the given string "(b, (b,b))" belongs to the above
grammar.
OR
8 (b) Construct CLR and LALR set of items for the following grammar: 12 CO2 L3
S -> BB*
B-> cB
B->d
Parse the String cccd* using CLR parsingtable.
9 (a) () With a proper
L-attributed
for the following expressiondefinition, draw an annotated parse tree 8 CO3 L3
using inherited attributes:
b-4*a +c
Show the steps of constructing the syntax tree and
expression with suitable SDD: DAG for the CO3 L2
(c+d)-(c+d)*(c-d) +(-d)
OR
9(b Write down the semantic actions for the
Translation of 8
Expressions and translate the CO3 L3
the three address code using followingexpression to generate
annotated parse tree:
X=a +b+ (c-dt-e)
Write down the semantic rules involved in width and
declaration and identify the type and width required fortypetheof array CO3 L2
following type declaration using annotated parse tree:
int [4] [3

PART- C(1 x12 =12 Marks)


(Q.No.10 is compulsory)
Q. No Questions Marks CO BL
Write down the translation scheme (semantic rules) used to
generate code for Boolean Expressions using Backpatching and 12 CO3 L3
translate the follovwing expression into intermediate code by
drawing an annotated parse tree u_ing true lists and false lists,
assuming the address of the first instruction generated is 100.
if ( a< 100|| a>200 && al=b) then a=0;
Roll No.

ANNA UNIVERSITY (UNIVERSITY DEPARTMENTS)

B.E. / B. Tech / B. Arch (Full Time) - END SEMESTER EXAMINATIONS, JAN/FEB 2022

INFORMATION TECHNOLOGY
Fifth Semester (V)
IT5502 & Compiler Engineering

(Regulation 2019)
Time: 3hrs Max.Marks: 100

CO 1 Understand the concept of lexical analysis and construction of deterministic and non-

deterministic automata.

CO 2 Understand the concept of parsing and construction of parser.

CO 3 Develop an Intermediate Code generator.

CO 4 Study programming language design, target machine design and run time environment

of compilers.

CO 5 Study about the compiler construction tools.

CO 6 Obtain knowledge to construct a prototype compiler for a subset of a programming

language.

BL – Bloom’s Taxonomy Levels


(L1 - Remembering, L2 - Understanding, L3 - Applying, L4 - Analysing, L5 - Evaluating, L6 - Creating)

PART- A (10 x 2 = 20 Marks)


(Answer all Questions)

Q. No Questions Marks CO BL
1 Draw a DFA for the language accepting strings ending with „10‟ 2 CO1 L5
over input alphabets ∑={0, 1}.

2 Find the Regular Expression corresponding to given statement, 2 CO1 L4


subset of {0,1}*. The Language of all strings containing at least
two 0‟s in the beginning, at least one 1 in the middle and at least
one 0 at end.

3 For the block-structured C code, indicate the values assigned 2 CO6 L3


to w,x,y and z.
int w,x,y,z;
int i = 6; int j = 3;
{
int i = 4;
w = i + j;
}
x = i + j;
{
Int j = 5;
int i = 2;
y = i + j;
}
z = i + j;

4 List at least four commonly used compiler construction tools. 2 CO5 L1

5 Consider the context-free grammar: 2 CO2 L3


S-> +SS | *SS | a
Write the left most derivation and right mot derivation for the string
++*+aaa

6 Eliminate left factors and left recursion in the following grammar 2 CO2 L3
for boolean expressions.
bexpr → bexpr or bterm∣ bterm
bterm → bterm and bfactor∣ bfactor
bfactor →not bfactor∣ (bexpr)∣ true∣ false

7 Differentiate L-attributed SDD from S-attributed SDD. 2 CO3 L4

8 Translate the arithmetic expression a*-b + ( b*c ) into Quadruples, 2 CO3 L3


Triples and Indirect Triples.

9 What are the issues in the design of a code generator? 2 CO4 L1

10 Construct DAG for the basic block: 2 CO4 L3


a=c*f
b=e+d
d=c*f
c=d-b

PART- B (5 x 13 = 65 Marks)
(Restrict to a maximum of 2 subdivisions)

Q. No Questions Marks CO BL
11 (a) (i) Construct NFA for the following regular expression and apply 9 CO1 L3
subset construction method to convert into DFA.
(a | b) ab (a|b)*

(ii) Construct the minimum-state DFA.for the DFA obtained in 11a)(i). 4 CO1 L3

OR

11 (b) (i) Construct DFA for the following regular expression without 9 CO1 L3
constructing NFA.
( a | b )* a b ( a | b )* #

(ii) Signed numbers are strings such as +1280, -31.67, +2.336E5 or - 4 CO1 L3
3.76E-3.
a) Give the regular definitions for the above mentioned strings.
b) Draw the state transition diagram for the signed numbers

12 (a) (i) Explain the phases of a Compiler and write down the output of 9 CO6 L2
each phase for the expression a := b + c * d / 3.
(ii) Identify the lexeme that make up the tokens in the following 4 CO1 L2
program segment. Indicate the corresponding token and pattern.

int checkPrimeNumber(int n)
{
int i, flag = 1, squareRoot;
squareRoot = sqrt(n);
for (i = 2; i <= squareRoot; ++i)
{
if (n % i == 0)
{
flag = 0;
break;
}
}
return flag;
}
OR
12 (b) (i) Write a Lex program that recognizes the tokens such as: if, then, 9 CO6 L4
else, while, relop, id and num.

(ii) Brief about Buffer pairs. What is the use of Sentinels in it? 4 CO1 L2

13 (a) (i) Devise predictive parser and show the parsing table for the 13 CO2 L3
following grammar:
S-> a | (R)
T-> S, T | S
R-> T
Check whether the given string “(a, (a,a))” belongs to the above
grammar.

OR
13 (b) (i) Construct a CLR parser for the following grammar: 13 CO2 L3
S →Ta | bTc |Xc | bXa
T→e
X→e
Parse the string “eaaaa” using the above grammar.
Check whether the given grammar is LALR(1)

14 (a) (i) Write the SDD with semantic actions for generating three address 9 CO3 L3
code for array references and translate the following assignment.

y = c[i][j] + d[i]+ a

(ii) With the proper L-attributed definition, draw a dependency graph 4 CO3 L3
for the following statement:
10 + 5 - (3 +7)

OR

14 (b) (i) Write the semantic actions for the translation of Expressions and 9 CO3 L3
translate the following expression to generate the three address
code using annotated parse tree:
x = a + b + (- d + - e)
(ii) Show the steps of constructing the syntax tree and DAG for the 4 CO3 L3
expression:
(a+b) - ((a+b) *(a-b)) + (a+b)

15 (a) (i) Explain how Peephole optimization can be applied to improve the 8 CO4 L2
intermediate code with an example for each of the characteristics
of optimization.

(ii) Generate intermediate code and target code for the expression 5 CO4 L4
x = (a-b) +(a+c)
OR
15 (b) (i) Assume the matrix entries are numbers that require 4 bytes, and 8 CO4 L4
that matrices are stored in row-major order.

Generate three address code and draw the flow graph for the
following code:

for (i = 1; i < n; i++)


{
key = arr[i];
j = i - 1;
while (j >= 0 && arr[j] > key)
{
arr[j + 1] = arr[j];
j = j - 1;
}
arr[j + 1] = key;
}

(ii) Optimize the three address code obtained from 15 (b)(i) by 5 CO4 L4
preserving the semantics of the original program.

PART- C (1 x 15 = 15 Marks)
(Q.No.16 is compulsory)

Q. No Questions Marks CO BL
16. (i) What is the intended use of short circuit code? 10 CO3 L5
Write the required Syntax Directed Definition and translate into
three address code for the statement:

if( a<b && b<d || e==f && c<d)


x=1 ;

(ii) Apply batckpatching to generate code for the same statement in 5 CO3 L3
one pass.

You might also like