adplus-dvertising
frame-decoration

Question

Consider 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.

a.

200

b.

180

c.

160

d.

40

Answer: (c).160

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Consider 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 {...

Similar Questions

Discover Related MCQs

Q. Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?

Q. Assume 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:

Q. In a bottom-up evaluation of a syntax directed definition, inherited attributes can

Q. Consider the grammar shown below S → i E t S S' | a S' → e S | ε E → b In the predictive parse table. M, of this grammar, the entries M[S', e] and M[S', $] respectively are

Q. Consider the grammar shown below.

S → C C
C → c C | d

The grammar is

Q. Consider 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

Q. Consider the syntax directed definition shown below.

S → id : = E {gen (id.place = E.place;);}
E → E1 + E2 {t = newtemp ( ); gen (t = El.place + E2.place;); E.place = t}
E → id {E.place = id.place;}

Here, gen is a function that generates the output code, and newtemp is a function that returns the name of a new temporary variable on every call. Assume that ti's are the temporary variable names generated by newtemp. For the statement 'X: = Y + Z', the 3-address code sequence generated by this definition is

Q. Which of the following statements is false?

Q. Which of the following derivations does a top-down parser use while parsing an input string? The input is assumed to be scanned in left to right order.

Q. Given the following expression grammar:

E -> E * F | F + E | F
F -> F - F | id

which of the following is true?

Q. Which one of the following is True at any valid state in shift-reduce parsing?

Q. In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the following is True?

Q. Match the following:

List-I List-II
A. Lexical analysis 1. Graph coloring
B. Parsing 2. DFA minimization
C. Register allocation 3. Post-order traversal
D. Expression evaluation 4. Production tree

Codes:
A B C D
(a) 2 3 1 4
(b) 2 1 4 3
(c) 2 4 1 3
(d) 2 3 4 1

Q. Among simple LR (SLR), canonical LR, and look-ahead 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?

Q. Consider the following grammar G.

S → F ⎪ H
F → p ⎪ c
H → d ⎪ c

Where S, F and H are non-terminal 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.

Q. A CFG G is given with the following productions where S is the start symbol, A is a non-terminal 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?

Q. Some code optimizations are carried out on the intermediate code because

Q. Which one of the following is FALSE?

Q. One of the purposes of using intermediate code in compilers is to

Q. Consider 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