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

Cse 3103

The document is an examination paper for the Compiler course at Bangladesh Army University of Engineering & Technology, detailing the structure and requirements for students to answer questions. It consists of two sections, with specific questions related to compiler design, code analysis, grammar, and optimization techniques. Students are required to answer a total of five questions, including a compulsory question from Section-A.

Uploaded by

Ferdous
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)
16 views2 pages

Cse 3103

The document is an examination paper for the Compiler course at Bangladesh Army University of Engineering & Technology, detailing the structure and requirements for students to answer questions. It consists of two sections, with specific questions related to compiler design, code analysis, grammar, and optimization techniques. Students are required to answer a total of five questions, including a compulsory question from Section-A.

Uploaded by

Ferdous
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

“Knowledge & Technology”

Bangladesh Army University of Engineering & Technology(BAUET)


Department of Computer Science and Engineering (CSE)
B.Sc. Engineering, 3rd Year 5th Semester Final Examination, Summer-2020
Course Code: CSE-3103
Course Title: Compiler
Full Marks: 40 Time: 02 Hours
N.B.:
1. Answering to question no. 1 is compulsory.
2. Answer four questions, taking two from each section.
3. Use separate script for each section.
4. Figures shown in the right margin indicate full marks.

Section-A

Q.1 (a) Illustrate diagrammatically how a language is processed. 2


(b) Identify the output result of each phase of compiler for the following statement. 3
Interest = initial * 50 + rate * 60 – L + h/5
(c) Suppose you are a developer. You are writing a code. In your code you declare an integer 3
variable but you assign integer array, you write if condition like iF and you also didn’t put
for loop end curly brace. But your code run perfectly well. What idea justify the problem
here? And what is the valid solution for this problem?
(d) What are the various issue involved in machine code generation. 2

Q.2 (a) What is the problem occur in triples? What is the solution for it? 1
(b) Find the error from the following code also mention that what kind of error is it? 3
#include<stdio.h>
#include<math.h>
int main()
{ int#MYVAR, hello@world;
scanf(“%i%i”, #MYVAR, hello@world);
if(#MYVAR);
{
printf(“This should print \n”);
}
int diameter = 5;
double area;
CONST int PI = acos(-1.0);
area = PI * (diameter/2) * (diameter/2);
printf(“%d”, area);
for(int i = 0, i < 100, i++ );
printf(“This should also print”);
return 5;
}
(c) Find out First and Follow from the following production rule. 6

S  aBDh
B  cC/Bwxc/BEghe
C  bC/Ɛ
D  EF/Dc/Djl
E  g/Ɛ
F  f/Ɛ

Q.3 (a) What is the main idea behind using two Buffer? 2
(b) Remove left factoring from the following grammar. 5
(i) S  a/ab/abc/abcd
(ii) S  SaSSbS/aSaSb/aSbb/b
(iii) E  E + T/T
(iv) S  E+ T/asvd/gfds/uhvv
(v) h  +-*ghT/T+ -jh/ +-hg/T+hgu

(c) Consider the following grammer: 3


X  YaYb | ZbZa
YƐ
ZƐ

1/2
(i) Using the definition of LL(1), explain why the grammar is or not LL(1)
(ii) Show whether the grammar is or is not SLR(1). (Treat “Ɛ” as a terminal)

Section-B
Q.4 (a) What is non-determinism? 2
(b) Write a code for Fibonacci series (using loop) in any language. Then draw control flow 5
graph for that code.
(c) Judge the effects of global optimization with proper example. 3

Q.5 (a) Mention the front-end phase of compiler. 2


(b) Write down the grammar type for the following grammar with proper explanation. 8
(i) S -> AB
A -> a
B ->b
(ii) S -> ab
(iii) S -> AB
AB -> abc
B -> b
(iv) Sab -> ba
A ->S

Q.6 (a) Write the difference between high-level and low-level IR. 2
(b) Write a regular expression for an identifier, Phone number and email address. 3
(c) Write down the optimized code for the following code. And also mention the name of 5
optimization technique.
(i) S1 = 4xi
S2 = a[S1]
S3 = 4xj
S4 = 4xi
S5 = n
S6 = b[S4] + S5
(ii) for (int j = 0 ; j < n ; j++)
{
x = y+z
a[j] = 6*j;
}
(iii) i=0
if(i = = 1)
{
a = x +5;
}
(iv) B = A*2

2/2

You might also like