Quizsummary
0 of 35 questions completed
Questions:
 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
Information
 35 Questions (Selected Randomly)
 45 Minutes of Time
This quiz consists of questions from Compiler Design for GATE 2019 preparation.
All The Best!
You must specify a text. 

You must specify a text. 
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 35 questions answered correctly
Your time:
Time has elapsed
You have scored 0 of 0 points, (0)
Average score 

Your score 

Categories
 Not categorized 0%
 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 Answered
 Review

Question 1 of 35
1. Question
1 pointsConsider the following two statements:
P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammarWhich of the following is TRUE?

Question 2 of 35
2. Question
1 pointsWhich of the following derivations does a topdown parser use while parsing an input string? The input is assumed to be scanned in left to right order.

Question 3 of 35
3. Question
1 pointsWhich of the following describes a handle (as applicable to LRparsing) appropriately?

Question 4 of 35
4. Question
1 pointsConsider the following statements:
(I) The output of a lexical analyzer is groups of characters.
(II) Total number of tokens in printf(“i=%d, &i=%x”, i, &i); are 11.
(III) Symbol table can be implementation by using array and hash table but not tree.Which of the following statement(s) is/are correct?

Question 5 of 35
5. Question
1 pointsConsider the following expression grammar. The semantic rules for expression calculation are stated next to each grammar production.
E → number E.val = number. val
 E ‘+’ E E(1).val = E(2).val + E(3).val
 E ‘×’ E E(1).val = E(2).val × E(3).val
The above grammar and the semantic rules are fed to a yacc tool (which is an LALR (1) parser generator) for parsing and evaluating arithmetic expressions. Which one of the following is true about the action of yacc for the given grammar?

Question 6 of 35
6. Question
1 pointsThe grammar S → aSa  bS  c is

Question 7 of 35
7. Question
1 pointsConsider the following grammar.
S > S * E
S > E
E > F + E
E > F
F > idConsider the following LR(0) items corresponding to the grammar above.
(i) S > S * .E
(ii) E > F. + E
(iii) E > F + .EGiven the items above, which two of them will appear in the same set in the canonical setsofitems for the grammar?

Question 8 of 35
8. Question
1 pointsWhich of the following statements is false?

Question 9 of 35
9. Question
1 pointsWhich one of the following is a topdown parser?

Question 10 of 35
10. Question
1 pointsConsider the grammar rule E → E1 – E2 for arithmetic expressions. The code generated is targeted to a CPU having a single user register. The subtraction operation requires the first operand to be in the register. If E1 and E2 do not have any common sub expression, in order to get the shortest possible code

Question 11 of 35
11. Question
1 pointsWhich of the following suffices to convert an arbitrary CFG to an LL(1) grammar?

Question 12 of 35
12. Question
1 pointsConsider the grammar with the following translation rules and E as the start symbol.
E → E1 # T { E.value = E1.value * T.value }
 T{ E.value = T.value }T → T1 & F { T.value = T1.value + F.value }
 F{ T.value = F.value }F → num { F.value = num.value }
Compute E.value for the root of the parse tree for the expression: 2 # 3 & 5 # 6 & 4.

Question 13 of 35
13. Question
1 pointsA CFG G is given with the following productions where S is the start symbol, A is a nonterminal and a and b are terminals.
S→aS∣A
A→aAb∣bAa∣ϵFor the correct answer in Q75, how many steps are required to derive the string and how many parse trees are there?

Question 14 of 35
14. Question
1 pointsThe grammar A → AA  (A)  ε is not suitable for predictiveparsing because the grammar is

Question 15 of 35
15. Question
1 pointsConsider the following expression grammar. The semantic rules for expression calculation are stated next to each grammar production.
E → number E.val = number. val
 E ‘+’ E E(1).val = E(2).val + E(3).val
 E ‘×’ E E(1).val = E(2).val × E(3).valAssume the conflicts in Part (a) of this question are resolved and an LALR(1) parser is generated for parsing arithmetic expressions as per the given grammar. Consider an expression 3 × 2 + 1. What precedence and associativity properties does the generated parser realize?

Question 16 of 35
16. Question
1 pointsAssume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between n1 and n2 is:

Question 17 of 35
17. Question
1 pointsIn a compiler, keywords of a language are recognized during

Question 18 of 35
18. Question
1 pointsThe number of tokens in the following C statement is
printf(“i = %d, &i = %x”, i, &i);

Question 19 of 35
19. Question
1 pointsThe output of a lexical analyzer is

Question 20 of 35
20. Question
1 pointsConsider the following two sets of LR(1) items of an LR(1) grammar.
X > c.X, c/d
X > .cX, c/d
X > .d, c/d
X > c.X, $
X > .cX, $
X > .d, $Which of the following statements related to merging of the two sets in the corresponding LALR parser is/are FALSE?
1. Cannot be merged since look aheads are different.
2. Can be merged but will result in SR conflict.
3. Can be merged but will result in RR conflict.
4. Cannot be merged since goto on c will lead to two different sets. 
Question 21 of 35
21. Question
1 pointsConsider the intermediate code given below
1. i = 1
2. j = 1
3. t1 = 5 * i
4. t2 = t1 + j
5. t3 = 4 * t2
6. t4 = t3
7. a[t4] = –1
8. j = j + 1
9. if j <= 5 goto(3)
10. i = i + 1
11. if i < 5 goto(2)The number of nodes and edges in the controlflowgraph constructed for the above code, respectively, are

Question 22 of 35
22. Question
1 pointsAmong simple LR (SLR), canonical LR, and lookahead LR (LALR), which of the following pairs identify the method that is very easy to implement and the method that is the most powerful, in that order?

Question 23 of 35
23. Question
1 pointsConsider the grammar with nonterminals N = {S,C,S1 },terminals T={a,b,i,t,e}, with S as the start symbol, and the following set of rules:
S –> iCtSS1a
S1 –> eSϵ
C –> bThe grammar is NOT LL(1) because:

Question 24 of 35
24. Question
1 pointsConsider the grammar defined by the following production rules, with two operators ∗ and +
S –> T * P
T –> U  T * U
P –> Q + P  Q
Q –> Id
U –> IdWhich one of the following is TRUE?

Question 25 of 35
25. Question
1 pointsMatch the following:
ListI ListII
A. Lexical analysis 1. Graph coloring
B. Parsing 2. DFA minimization
C. Register allocation 3. Postorder traversal
D. Expression evaluation 4. Production treeCodes:
A B C D
(a) 2 3 1 4
(b) 2 1 4 3
(c) 2 4 1 3
(d) 2 3 4 1

Question 26 of 35
26. Question
1 pointsConsider the following grammar:
S → FR
R → S  ε
F → idIn the predictive parser table, M, of the grammar the entries M[S, id] and M[R, $] respectively

Question 27 of 35
27. Question
1 pointsConsider the grammar
S → (S)  a
Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar be n1, n2 and n3 respectively. The following relationship holds good

Question 28 of 35
28. Question
1 pointsConsider the following grammar G.
S → F ⎪ H
F → p ⎪ c
H → d ⎪ cWhere S, F and H are nonterminal symbols, p, d and c are terminal symbols. Which of the following statement(s) is/are correct?
S1: LL(1) can parse all strings that are generated using grammar G.
S2: LR(1) can parse all strings that are generated using grammar G.

Question 29 of 35
29. Question
1 pointsWhich of the following statements are TRUE?
I. There exist parsing algorithms for some programming languages whose complexities are less than O(n^3).
II. A programming language which allows recursion can be implemented with static storage allocation.
III. No Lattributed definition can be evaluated in The framework of bottomup parsing.
IV. Code improving transformations can be performed at both source language and intermediate code level.

Question 30 of 35
30. Question
1 pointsConsider the translation scheme shown below
S → T R
R → + T {print (‘+’);} R  ε
T → num {print (num.val);}Here num is a token that represents an integer and num.val represents the corresponding integer value. For an input string ‘9 + 5 + 2’, this translation scheme will print

Question 31 of 35
31. Question
1 pointsThe lexical analysis for a modern computer language such as Java needs the power of which one of the following machine models in a necessary and sufficient sense?

Question 32 of 35
32. Question
1 pointsConsider the grammar shown below.
S → C C
C → c C  dThe grammar is

Question 33 of 35
33. Question
1 pointsConsider a program P that consists of two source modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2, the reference will be resolved at

Question 34 of 35
34. Question
1 pointsOne of the purposes of using intermediate code in compilers is to

Question 35 of 35
35. Question
1 pointsWhich one of the following is True at any valid state in shiftreduce parsing?