Compre 2023 B
Compre 2023 B
if i<=10 go to Bó
d3: t1 = 10 *i
d4: t2 = ti +j 18,
3,
d5: t3 = 8 * t2
d6: t4 = t3 - 88 d9: i= 1 BS B (
d7:j =j+l
ifj<=10go to B3
d8: i=i +1
B3 if i<=10 go to B2 B4
1,9,
13
a) Çompute the GEN set by performing the localanalysis within the boundaries of allthe basic blocks.
b Find out the KILL set by performing areaching definition analysis on all the basic blocks locally.
rAlso, show the step-by-step computation of IN and OUT sets in all the required iterations.
Q3.
Consider the following CFG [ES. (if. exp. then, else. while, do, begin, end,
P, S]where S is the start symbol and Plist}.
is defined as otherstatements, i
follows: [2+4+3 = 9 MJ
S’ if exp then S1
|ifexp then Selse S R
|whileexp do S)
|begin list endFa
|otherstatements
list ’ list; Sy
|S
sa) Generate the Augmented Grammar and compute the closure ofS'>.S(where S' is the new start symbol
of above CFG. 19slalt
Ab) Design the DFA of LR (0) items indicating all the valid LR (0) items in each state.
yConstruct the LR (0) parsing table clearly indicating the shift and reduce entries in the ACTION and
GOTO part of all the states.
(e.g., 0342,
Q4. A language allows decimal, hexadecimal (e.g. XF234. XA23FF, and so on), octal numbers23.4E12, 34.9E
0654, O111, and so on), and real numbers using both exponent and mantissa form (e.g.
prefix X and O specity
16, 1.5e+12, and so on) and simple decimal point form (e.g. 23.45,45.39 etc.). The real number can use
the hexadecimal and octal numbers respectively. The exponent and mantissa form of a
signed or unsigned exponent values, using upper or lower case E ore for exponent. Write the regular
Deterministic Finite Automaton. Clearly
expressions for these five different types of numbers and draw the
Make sure that the DFA has one start state only.
DFA.
WTitethe responsibilities of each accept state in the [10 M]
the first nesting
Consider a symbol table T implementing the nested static scopes with functions atkey k so that T[k]
Q5.
tables such that h[<function name>]hashes toa
level. The symbol table is a tree of hash nesting level 1. The static children of the function get associated
points to the hash table of variables at the so that deeper nested scopes are implemented with deeper hash
way
withthis hash table in a hierarchicallinks are one way and children can access the parent's hash table only
Parent-to-child that maps
tables appropriately.
hash function for mapping function names and p is a hash function
using explicit stack. Ifh isthe necessary fields of table
names to unique keys, then answer the following questions. Specify
example. [6x2M=12M]
the variable contents of the symboltable using an appropriate
entries of T. and draw the
recursion? Cyclic
you implement the symbol table ifthe language does not allow cyclic function (say f2).
(a)How will when one function (say fl) calls
another
recursion refers to the recursion occurring and illustrate using an example.
the logic
and f2 calls fl, and so on. Explain table for accessing the non-local variables from their static
symbol
b) How will you implement theand illustrate using an example.
ancestors? Explain the logic