Compiler Design questions

Q9

GATE CS 2020 CSRuntime EnvironmentsMCQ1 mark−1/3 if wrong
Consider the following statements.

I. Symbol table is accessed only during lexical analysis and syntax analysis.
II. Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment.
III. Errors violating the condition ‘any variable must be declared before its use’ are detected during syntax analysis.

Which of the above statements is/are TRUE?
Show answer without attempting

Answer: D

Q24

GATE CS 2020 CSParsingNAT1 mark
Consider the following grammar.

S→aSB∣dS \rightarrow aSB \mid d
B→bB \rightarrow b

The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbbaaadbbb is __________.
Show answer without attempting

Answer: 7

Q33

GATE CS 2020 CSSyntax Directed TranslationMCQ2 marks−2/3 if wrong
Consider the productions A→PQA \rightarrow PQ and A→XYA \rightarrow XY. Each of the five non-terminals A, P, Q, X, and Y has two attributes: ss is a synthesized attribute, and ii is an inherited attribute. Consider the following rules.

Rule 1: P.i=A.i+2P.i = A.i + 2, Q.i=P.i+A.iQ.i = P.i + A.i, and A.s=P.s+Q.sA.s = P.s + Q.s

Rule 2: X.i=A.i+Y.sX.i = A.i + Y.s and Y.i=X.s+A.iY.i = X.s + A.i

Which one of the following is TRUE?
Show answer without attempting

Answer: B

0/30 correct0 marks

Related topics in GATE CS