0% found this document useful (0 votes)
2 views

Compiler-3

This document outlines the details for the CE442: Design of Language Processor external theory exam at Charotar University of Science and Technology. It includes instructions for the exam format, consisting of multiple-choice questions and descriptive questions, along with a list of questions categorized by sections. The exam is scheduled for November 24, 2021, and is worth a total of 70 marks.

Uploaded by

jaymehta11th
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Compiler-3

This document outlines the details for the CE442: Design of Language Processor external theory exam at Charotar University of Science and Technology. It includes instructions for the exam format, consisting of multiple-choice questions and descriptive questions, along with a list of questions categorized by sections. The exam is scheduled for November 24, 2021, and is worth a total of 70 marks.

Uploaded by

jaymehta11th
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Candidate seat No: _______________

Charotar University of Science and Technology


Devang Patel Institute of Advance Technology and Research
Department of Computer Engineering

Subject: CE442: DESIGN OF LANGUAGE PROCESSOR

University External Theory Exam

Semester: 7th (B. Tech.) Maximum Marks: 70


Date: 24/11/2021, Wednesday Time: 01:30 pm to 04:30 pm

Instructions:
(i) MCQ (20 Marks) +Descriptive (50 Marks) =70 Marks.
(ii) In descriptive section solve any 10 questions out of 15 questions

Sr. Questions Marks CO BL


No
Section-1-MCQ
1 Analysis which determines the meaning of a statement once its 1 4 N
grammatical structure becomes known is termed as
a. Semantic analysis
b. Syntax analysis
c. Regular analysis
d. General analysis
2 The process of assigning load addresses to the various parts of the 1 6 R
program and adjusting the code and data in the program to reflect the
assigned addresses is called
a. Assembly
b. Parsing
c. Relocation
d. Symbol resolution

3 Which of the following is the important factor that justifies the use of a 1 2 U
stack in shift-reduce parsing?
a. The handle will always appear on top of stack and never inside
b. The handle will always appear inside the stack and never on top
c. The handle will never appear in stack
d. None of the above

4 Problem definition : “Implement the ios based application for 1 1 A


CHARUSAT hospital”. Identify the application domain.
a. CHARUSAT
b. CHARUSAT hospital
c. ios based device
d. any mobile device

5 Consider the following grammar: E→E*E | E+E |(E)| int. 2 2 A


How many unique parse trees are there for the string 5*3+(2*7)+4?
a. 3
b. 4
c. 5
d. 7

6 Consider the below grammar 2 2 E


S→ABa | bCA
A→cBCD| ε
B→CdA | ad
C→eC |ε
D→bsf| a
What is follow(B)?
a. {a,b,e,d,$}
b. {a,b,e,$}
c. {a,b,d,$}
d. {a,b,e}

7 Which of the following describes a handle (as applicable to LR-parsing) 1 2 U


appropriately?
a. It is the position in a sentential form where the next shift or reduce
operation will occur.
b. It is non-terminal whose production will be used for reduction in the
next step.
c. It is a production that may be used for reduction in a future step along
with a position in the sentential form where the next shift or reduce
operation will occur.
d. It is the production p that will be used for reduction in the next step
along with a position in the sentential form where the right-hand
side of the production may be found.

8 Consider the following translation scheme. 2 3 A


S → ER
R → *ER {print (“*”);}
R→ε
E → F + E {print (“+”);}
E→F
F → (S)
F → id {print(id.value);}
Here id is a token that represents an integer and id.value represents the
corresponding integer value. For an input ‘2 * 3 + 4’, this translation
scheme prints.
a. 2 * 3 + 4
b. 2 * +3 4
c. 2 3 * 4 +
d. 2 3 4+*

9 what will be the output of preprocessor after giving below program as 1 1 E


input?
#define A(a) (a*a)*pi
#define P 22/7
void main ()
{
float b;
b = A(10);
}
a. void main () {float b ; b = 10*10*(22/7);}
b. void main () {float b ; b = (10*10)*22/7;}
c. void main () {float b ; b = (10*10)*pi;}
d. void main () {float b ; b = (10*10)*(22/7);}
e. void main () {float b ; b = (a*a)*pi;}

10 Which of the following is not valid three address code? 1 4 N


a. X = -Y
b. X = Y
c. X = Y + Z
d. X[i] = Y[j]

11 Select an appropriate approach for obtaining information about the flow of 1 5 U


data along program execution routes.
a. Dataflow Analysis
b. Dataflow Line
c. Dataflow None
d. None of the above.

12 Which of the following load resides in ROM? 1 1 R


a. Compile and go loader
b. OS loader
c. Bootstrap loader
d. Linking loader

13 In compiler terminology reduction in strength means 1 1 U


a. replacing a costly operation by a relatively cheaper one
b. Replacing run time computation by compile time computation
c. Removing common subexpressions
d. Removing loop invariant computation
14 In given program there are 3 user defined functions (1) main (2) f1 (3) 1 6 N
f2. In main there is a call of f1 and from f1 there is a call for f2. During
program execution, when call for f1 will encounter in main at that time
f1 will be linked and when call of f2 encountered in f1 then f2 will be
linked. Choose appropriate from link for given scenario.
a. Dynamic linking
b. Absolute loader
c. Linkage editor

15 Select the correct expansion order of the given macro call. 1 6 A


computer ( charusat(x) , cspit(y) )
a. computer -> charusat -> cspit
b. charusat -> cspit -> computer
c. computer -> cspit -> charusat
d. not defined

16 For a C program accessing X[i] [j] [k], the following intermediate code is 2 4 N
generated by a compiler. Assume that the size of an integer is 32 bits and
the size of a character is 8 bits.
t0 = i * 1024
t1 = j * 32 t
2=k*4
t3 = t1 + t0
t4 = t3 + t2
t5 = X[t4]
Which one of the following statements about the source code for the C
program is CORRECT?
a. X is declared as “int X[32] [32] [8]”.
b. X is declared as “int X[4] [1024] [32]”.
c. X is declared as “char X[4] [32] [8]”.
d. X is declared as “char X[32] [16] [2]”.

Section-2-Decriptive-Solve any 10 out of 15 questions


17 Justify that following grammar is not LL (1), not SLR (1) but it is CLR 5 2 N
(1).
S→Aa | bAc |Bc | bBa
A→d
B→d
18 What is a role of a linker and a loader? List out types of loaders and 5 1 R
discuss in detail.
19 Compute the operator precedence relation table and precedence relation 5 5,6 C
graph for given grammar.
G→E
E→E+T
T→T*F
F → id

20 Consider the below given macro definition and macro call. Write the 5 6 C
code after macro expansion.
Macro definition:
MACRO
F1 &X
MOVER AREG , X
GBL &K
&K SET 1
.NEXT ADD AREG , 1
&K SET &K+1
AIF (&K LE 4) .NEXT
MEND
Macro call:
F1 100

21 Symbol Table is an important data structure created and maintained by 5 1 U


the compiler. What information is stored in symbol table? Also explain
which data structures are used to implement symbol table with its pros
and cons.
22 Differentiate between s-attributed Syntax Directed Translation (S-SDT) 5 2 A
and L-attributed Syntax Directed Translation (L-SDT).
Find the number of Shift-Reduce (SR) and Reduce-Reduce (RR) conflict
in LR(0) item set for following grammar.
S→SS | a | ϵ
23 Write the machine code for the below given assembly code. Also show 5 6 C,A
the content of all data structures if processing using single pass
assembler.
START 500
MOVER BREG , =’29’
MOVER CREG , DATE
LTORG
NEXT ADD BREG , CREG
BC LE , NEXT
STOP
DTAE DS 10
END

24 Find basic block and draw control graph for following code written in 5 5 C
higher level language.
fact(x) {
int f = 1;
for (i = 2; i <= x; i++)
f = f * i;
return f;
}
25 Why there is a need to have intermediate code generation phase? Explain 5 4 U
any two techniques to implement three address code.

26 Write down the goals of an error handler in a parser. What are the different 5 2 U
error strategies used by a parser to recover from a syntactic error?

27 Explain the technique that reduces the amount of overhead required to 5 5 U


process an input character during scanning process.

28 What is run time environment? Give brief idea of memory allocation 5 3 R


done during compilation with block structured language. What are the
limitations of stack-based memory allocation?

29 Consider the following grammars: 5 2 E


G1 S→ Sb| aSb |b
G2 S→Sa| Sb |c
G3 S→SaS | ϵ
G4 S→bTT→aT |ϵ
Let n = number of grammars where there exists a string that has at least
two different left-most derivations, m= number of grammars where for
any string, we only have one parse tree and k=the number of grammars
that can be used with a brute force approach of top-down parsing. What
is the correct value of n, m and k?
30 What are the conditions for any grammar to be LL(1) ? Compute First 5 2 E
and Follow sets of following non-terminal.
E → TE'
E' → + TE' | ε
T → FT'
T' → *FT' | ε
F → id | (E)
31 List out phases of a compiler. Explain working of each phase with an 5 1 R
example.

Note:
CO – Course Outcomes
BL – Bloom’s Taxonomy Level

Legends: 1. R: Remembrance; 2. U: Understanding; 3. A: Application, 4. N: Analyze 5. E: Evaluate 6. C:


Create

You might also like