Question
S > ER
R > * E{print{’ * ’);
R | f
E > F + E{print(’ + ’); | F F > (S) | id{print(id.value);}
Here id is a taken 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 + *
Posted under Compiler Design
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. Consider the following translation scheme. S > ER R > * E{print{’ * ’); R | f E > F + E{print(’ + ’); | F F > (S) | id{print(id.value);} Here id is a taken that...
Similar Questions
Discover Related MCQs
Q. Consider the following C code segment.
for if i # i } } }
Which one to the following false?
View solution
Q. E -> number Eval number val
E E .val E .VAL E .val
E # E E .val E .VAL E .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?
View solution
Q. E -> number Eval number val
E E .val E .VAL E .val
E # E E .val E .VAL E .val
;
Assume the conflicts 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?
View solution
Q. Consider the following grammar.
S -> S * E
S -> E
E -> F + E
E -> F
F -> id
Consider the following LR (0) items corresponding to the grammar above.
(i) S -> S * .E
(ii) E -> F. + E
(iii) E “F + .E
Given the items above, which two of them will appear in the same set in the canonical sets-of-items for the grammar?
View solution
Q. Consider the following grammar
S -> FR
R -> * S | ε
F -> id
In the predictive parser table, M, of the grammar the entries M [S, id] and M [R, $] respectively
View solution
Q. Consider the following translation scheme.
S -> ER
R -> * E{print{’ * ’);
R | f
E -> F + E{print(’ + ’); | F
F -> (S) | id{print(id.value);}
Here id is a taken that represents an integer and id. value represents the corresponding integer value. For an input ‘2 * 3 + 4’, this translation scheme prints
View solution
Q. Consider the following C code segment.
for for if i # i } } }
Which one to the following false?
View solution
Q. Which one of the following grammars generates the language
L = (a i b i | i ! j}?
View solution
Q. In the correct grammar above, what is the length of the derivation (number of steps starting from S to generate the string a l b m with l ! m?
View solution
Q. Consider the grammar with non-terminals
N = {S , C , S}, terminals T = {a, b , i , t, e}, with S as the start symbol, and the following of rules
S -> iCtSS1 | a
S1 -> eS | ε
C -> b
The grammar is NOTLL(1) because:
View solution
Q. Consider the following two statements:
P: Every regular grammar is LL(1)
Q: Every regular set has LR(1) grammar
Which of the following is TRUE?
View solution
Q. In a simplified computer the instructions are:
OP R j , Ri − Performs Rj OP Ri and stores the result in register Ri
OP m, Ri − Performs val OP Ri abd stores the result in Ri. value
denotes the content of memory location m.
MCVm, Ri −Moves the content off memory loction m to register Ri .
MCVm, Ri , m −Moves the content of register Ri to memory location m.
The computer has only two registers, and OP is either ADD or SUB. Consider the following basic block:
t1 = a + b
t2 = c + d
t 3 = e − t2
t 4 = t 1 − t2
Assume that all operands are initially in memory. The final value of the computation should be in memory. What is the minimum number of MOV instructions in the code generated for this basic block?
View solution
Q. S->bA S->aB
A->a B->b
A->aS B->bS
A->bAA B->aBB
Which of the following strings is generated by the grammar?
View solution
Q. S->bA S->aB
A->a B->b
A->aS B->bS
A->bAA B->aBB
how many derivation trees are there?
View solution
Q. Which of the following are true?
(i) A programming language option does not permit global variables of any king and has no nesting of procedures/functions, but permits recursion can be implemented with static storage allocation
(ii) Multi-level access link (or display) arrangement is needed to arrange activation records-only if the programming language being implemented has nesting of procedures/function
(iii) Recursion in programming languages cannot be implemented with dynamic storage allocation
(iv) Nesting of procedures/functions and recursion require a dynamic heap allocation scheme and cannot be implemented with a stack-based allocation scheme for activation records
(v) Languages which permit a function to return a function as its result cannot be implemented with a stack-based storage allocation scheme for activation records
View solution
Q. An LALR(1) parser for a grammar can have shift-reduce (S-R) conflicts if and only if
View solution
Q. Which of the following statements are TRUE ?
I There exist parsing algorithms for some programming languages hose complex are less than θ(n 3 )
II A programming language which allows recursion can be implemented with static storage allocation
III No L-attributed definition can be evaluated in the framework of bottom-up parsing
IV Code improving transformations can be performed at both source language and intermediate code level
View solution
Q. What data structure in a complier is used for managing information about variables and their attributes?
View solution
Q. Which languages necessarily need heap allocation in the runtime environment?
View solution
Q. Given the language L-{ab, aa, baa}, which of the following strings are in LG?
1) abaabaaabaa
2) aaaabaaaa
3) baaaaabaaaab
4) baaaaabaa
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Compiler Design? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!