While creating the object module, the compiler’s response about line no. 3 is
(A) Only syntax error
(B) No compilation error
(C) Only lexical error
(D) Both lexical and syntax error
View Answer / Hide Answer
ANSWER: Only syntax error
(26) We have the translation scheme given below:
S->FR
R->*E{print(‘*’);R\ε
E->F + E{print (‘+’);\F
F->(S)\id {print (id.value);}
In the above translation scheme id represents the token in integer form and id value represents the corresponding integer value. What will be printed by this translation scheme when an input
is ‘2 * 3 + 4’?
(A) 2 3 * 4 +
(B) 2 3 4 + *
(C) 2 * + 3 4
(D) 2 * 3 + 4
View Answer / Hide Answer
(27) We have the grammar with the translation rules:
E->E1 # T {E.value = E1.value * T.value}
I T {E.value = T.value}
T->T1 & F {T.value = T1.value F.value}
I F {T.value = F.value}
F->num {F.value = num.value}
In the above grammar E is the start symbol. What will be the value of E for the root parser tree for the expression 2 # 3 & 5 # 6 & 4?
(A) 50
(B) 100
(C) 200
(D) 160
View Answer / Hide Answer
(28) For the expression grammar
E->E*F I F+E I F
F->F – I id
The statement, which holds true, is
(A) + and – have same precedence
(B) Precedence of * is higher +
(C) Precedence of - is higher *
(D) Precedence of + is higher *
View Answer / Hide Answer
ANSWER: Precedence of - is higher *
(29) Which one of the following statement holds true for a bottom-up evaluation of syntax directed definition?
(A) Inherited attributes can always be evaluated
(B) Inherited attributes can never be evaluated
(C) Inherited attributes can be evaluated only if the definition is L-attributed
(D) Inherited attributes can be evaluated only if the definition has synthesized attributes
For questions 30 and 31 refer to the data given below:
{S, A, B} is the non-terminal alphabet and {a, b} is the terminal alphabet of the CFG. S is the start symbol. The set of production rules are given below,
S->aB S->bA
B->b A->a
B->bS A->aS
B->aBB A->bAA
View Answer / Hide Answer
ANSWER: Inherited attributes can be evaluated only if the definition has synthesized attributes
(30) The string that is generated by the grammar is
(A) aabbbb
(B) abbbba
(C) aabbab
(D) aaaabb
View Answer / Hide Answer
(31) The number of derivation trees for the correct answer strings to question 30 is
(A) 4
(B) 1
(C) 3
(D) 2
View Answer / Hide Answer
(32) For a grammar G, Shift reduce (S-R) conflicts is present in LALR (1) parser, if and only if
(A) The LR (1) parser for G has S-R conflicts
(B) The LR (0) parser for G has S-R conflicts
(C) The SLR (1) parser for G has S-R conflicts
(D) The SLR (0) parser for G has S-R conflicts
View Answer / Hide Answer
ANSWER: The LR (1) parser for G has S-R conflicts
(33) For arithmetic expression the grammar rule is E->E1-E2. A CPU has a single user register and the code generated is target to the CPU. The first operand should be in the register for the subtraction operation. E1 and E2 do not have any common sub-expression. Which one of the following is true in order to get the shortest possible code?
(A) Order of evaluation of E1 and E2 has no consequence
(B) E1 and E2 evaluation should be interleaved
(C) E2 should be evaluated first
(D) E1 should be evaluated first
View Answer / Hide Answer
ANSWER: E2 should be evaluated first
(34) Consider the grammar G whose SLR parser has n1 states and LALR parser has n2 states. What is the relation between n1 and n2?
(A) n1 = n2
(B) n1 < n2
(C) n1 > n2
(D) None of the above
View Answer / Hide Answer
(35) A program P has M1 and M2, the two source modules contained in two different files. When is the reference resolved if M1 contains reference to a function defined in M2?
(A) Edit time
(B) Load time
(C) Compile time
(D) Link time
View Answer / Hide Answer
(36) For predictive parsing the grammar A->AA I (A) I ε is not suitable because
(A) The grammar is right recursive
(B) The grammar is left recursive
(C) The grammar is ambiguous
(D) The grammar is an operator grammar
View Answer / Hide Answer
ANSWER: The grammar is left recursive
(37) How many tokens are there in the following C statement?
printf (“j=%d, &j=%x”, j&j)
(A) 4
(B) 5
(C) 9
(D) 10
View Answer / Hide Answer
(38) Assuming that the input is scanned in left to right order, while parsing an input string the top-down parser use
(A) Rightmost derivation
(B) Leftmost derivation
(C) Rightmost derivation that is traced out in reverse
(D) Leftmost derivation that is traced out in reverse
View Answer / Hide Answer
ANSWER: Rightmost derivation
(39) To convert an arbitrary CFG to an LL (1) grammar
(A) Factor the grammar alone
(B) Remove left recursion alone
(C) Remove left recursion and factor the grammar
(D) None of the above
View Answer / Hide Answer
ANSWER: Remove left recursion and factor the grammar
(40) S->S*E
S->E
E->F+E
E->F
F->Id
Corresponding to the above grammar, we have following LR (0) items.
a. S->S*E
b. E->F.+E
c. E->F+.E
The two items that will appear in the same set in the canonical sets-of-items for the grammar is
(A) a and c
(B) a and b
(C) b and c
(D) a, b and c
View Answer / Hide Answer
(41) __________________ is a top-down parser
(A) Operator precedence parser
(B) An LALR (k) parser
(C) An LR (k) parser
(D) Recursive descent parser
View Answer / Hide Answer
ANSWER: Recursive descent parser
(42) Why is the code optimizations are carried out on the intermediate code?
(A) Because for optimization information from the front end cannot be used
(B) Because program is more accurately analyzed on intermediate code than on machine code.
(C) Because for optimization information from data flow analysis cannot be used
(D) Because they enhance the portability of the compiler to the other target processor.
View Answer / Hide Answer
ANSWER: Because program is more accurately analyzed on intermediate code than on machine code.
(43) In a compiler, when is the keyboards of a language are recognized?
(A) During the lexical analysis of a program
(B) During parsing of the program
(C) During the code generation
(D) During the data flow analysis
View Answer / Hide Answer
ANSWER: During the lexical analysis of a program
(44) In a compiler, the data structure responsible for the management of information about variables and their attributes is
(A) Semantic stack
(B) Parser table
(C) Symbol table
(D) Abstract syntax-tree
View Answer / Hide Answer
(45) The lexical analysis for Java needs _____________ in a necessary and sufficient sense.
(A) Turing machine
(B) Non-deterministic push down automata
(C) Deterministic push down automata
(D) Finite state automata
View Answer / Hide Answer
ANSWER: Finite state automata