0% found this document useful (0 votes)
41 views32 pages

PYQ Sem 5

Uploaded by

Karamjot Kaur
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)
41 views32 pages

PYQ Sem 5

Uploaded by

Karamjot Kaur
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/ 32

[This question paper contains 8 printed pages.

Your Roll No ............. ..

Sr. No. of Question Paper : 1094 C


Unique Paper Code 32347501
Name of the Paper System Programming

Name of the Course B.Sc. (H) Computer Science

Semester V

Duration : 3 Hours Maximum Marks : 75

Instructions for Candidates

1. Write your Roll No. on the top immediately on receipt

\ 2.
of this question paper.

Section A is compulsory.

3. Attempt any four questions from Section B.


4. Make and state necessary assumptions wherever
applicable.

SECTION A

1. (a) Which phase of a compiler will generate error if


a semicolon is missing in a C program. ( 1)

(b) Differentiate between pseudo opcodes "DB" and


"RESB". (2)

P.T.O.
C

1094 2

(c) What is the purpose of "yytext" and "yyleng"


variables in a Lex program? ()
2

(d) Explain the structure of a Pseudo-opcode table in


a two pass assembler.
(2)

(e) Write regular expressions for the following


languages:

(i) All strings of x's and y's where number of


y' s is a multiple of three and there can be
any number of x's .

(ii) All Strings of letters that contain the five


vowels in the order. (2+ 1)

(f) Write a Lex program to count the number of


vowels and consonants in an input string. (3)

(g) Show whether the given grammar is ambiguous or


not by parsing the string w = abababb

E a / abEb I aFb
F bE I aFFb (3)

(h) Write three address-code for the following


arithmetic expression:

-( X * y) + (p + q) - (X + Y) (3)
1094 3
(i) Identify and list the possible lexemes, tokens and
their attribute values that would be identified by
the lexical analyzer while scanning the code
fragment.

if (x 20) then

mid= 10;

else

last = mid + gap; (4)

G) Translate the following arithmetic expression into


Quadruples :

a[i] = b[i] + cu] (4)

(k) Consider the following Syntax Directed Definition :

Production Semantic Rules


L En L. val = E. val
E T E.val = E1• val + T.val
E.val = T.val
T F T.val = Ti.val * F.val
T.val = F. val
F (E) F.val = E.val
F digit F.val = digit, lexval

Construct the annotated parse tree for (1 + 2 * (3


+ 4) + 5) * 6n. \ (4)
I
'
I
P.T.O.
\I
1094 4

(1) Determine and write the costs of the follo .


Wtng
instruction sequences :

LD RO, i

MUL RO, RO, 8

LD Rl, a(RO)

ST b, Rl
(4)

SECTION B

2. (a) Consider the following grammar :

.S aSIAb

XYZIE

X cSjE

y dSIE

z es (4)

Give leftmost derivation of the string"aebb".

(b) .Following are the section tables and symbol tables


for two object files namely, filel.obj and file2.obj .
-
....
1094 5 •

Using Pass 1 of linking process, populate the


Combined Section Table and Public Definition
Table.

Section Table of file1.0)1


b' S bol Table offilel.ob'
Name Size Alim Name Location Sec ID
.sec A 120 + ' Ll
.secB 50 16 L2
.secC 60 ·. 4

Section Table of file2.ob · S bol Table of file2.ob.


Name Size Ali Name Loe tion Section-ID
.sec B 50 Ll 1 1
.sec C 70 L2· 85 3.
.sec D 110
(6)

· 3. (a) Consider the following grammar:

E EalEc le··

Is the grammar LR(l )? Justify your answer.


,,
(7)

(b) What is the use of Machine Opcode Table (MOT)


in an assembly process? Explain its structure.
(3)

4. (a) Construct the Directed AcyGlic Graph for the


express10n (5)

:(<x:+ y) (~~r,.
...... ,,,, ,.· ... ,.

,:· .:- :~l·ex -y))


ljd~. ·

P.T.O.
6
1094
.d r the following Syntax Directed Defini·t·
(b) ons1 e ton:
C
Semantic Rules
production
L.attr := T.type
D TL
T.~ype := integer
T int
.T.type := float
T float
L1.attr :=
L LI' id
• " L.attr; addtype(id. entry, L.in)

Addtye(id., rntry, L.in)


L id
Identify and write ttirminal and non-terminal
symbols. List down the attributes associated with
the grammar symbols and also classify them as
synthesized and inherited. (5)

5.
(a) Find the First and Follow set of al~ non-terminal
for the following grammar: (5)
l
I
S ES' ,,,,,. .
'
/
S' +pS'/e
-
E ....,,
AE'

E' AE' IE

(S)/id
•·
1094 7

(b) Write a regular expression for a C language


identifier and also draw its transition diagram.
(5)

6. (a) Generate machine code for the following three


address sequen~e :

if x < y goto L1

z =0
goto L2

LI: z = 1

Assuming that x, y, and z are in memory locations.


(6)

(b) What is bottom-up parsing? Consider tl)e following


grammar: ·

E E + TIT

T T * FIF

F (E)lid

Draw the sequence of tree for the bottom-up parser


of token stream

id * id + id (4)

P.T.O .
!?I
~

1094 8

7. (a) What is the need of.. SYMT AB and Location


.
Counter (LC) in an assembly process? ()
4

(b) Consider the following context free grammar :

S daAe

daA IE

E EbP IP

P d I pAp

Is the grammar SLR( 1)? Justify your answer?


(6)
)

(1500)

You might also like