Semantic Analysis
GATE CSE & IT · 29 questions across 18 years (1990-2026) · 45% recurrence rate
Recurrence sparkline
1990–2026Difficulty mix
Question types
All 29 questions on Semantic Analysis
$$ \text { Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations. } $$ SDD1 Grammar(G1) $$ \text { Semantic Rules } $$ $$ \mathrm{D} \rightarrow \mathrm{TV} $$ $$ \begin{aligned} & \t...
Given the following syntax directed translation rules : Rule 1 : $R \rightarrow A B\{B . i=R . i-1 ; A . i=B . i R . i=A . i+1 ;\}$ Rule 2 : $P \rightarrow C D\{P . i=C . i+D . i ; D . i=C . i+2\}$ Rule 3 : $Q \rightarro...
Consider the following statements about the use of backpatching in a compiler for (I) Backpatching can be used to generate code for Boolean expression in one pass. (II) Backpatching can be used to generate code for flow-...
Which of the following statements is/are FALSE?
Consider the following syntax-directed definition (SDD). S → DHTU { S.val = D.val + H.val + T.val + U.val; } D → “M” D 1 { D.val = 5 + D 1 .val; } D → ε { D.val = –5; } H → “L” H 1 { H.val = 5 * 10 + H 1 .val; } H → ε {...
Consider the syntax directed translation given by the following grammar and semantic rules. Here N, I, F and B are non-terminals. N is the starting non-terminal, and #, 0 and 1 are lexical tokens corresponding to input l...
Consider the following grammar along with translation rules. S $$\to$$ S 1 # T {S.val = S 1 .val * T.val} S $$\to$$ T {S.val = T.val} T $$\to$$ T 1 %R {T.val = T 1 .val $$ \div $$ R.val} T $$\to$$ R {T.val = R.val} R $$\...
Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT) actions, given as pseudo-code: P → D* E* D → int ID {record that ID.lexe...
Consider the following ANSI C program: int main() { Integer x; return 0; } Which one of the following phases in a seven-phase C compiler will throw an error?
Consider the productions A $$ \to $$ PQ and A $$ \to $$ XY. Each of the five non-terminals A, P, Q, X, and Y has two attributes: s is a synthesized attribute, and i is an inherited attribute. Consider the following rules...
Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let $X_1, X_2, X_3, X_4, X_5$, and $X_6$ be the placeholders for the nonterminals $\mathrm{D}, \mathrm{T}, \ma...
Which one of the following statements is FALSE?
Consider the following Syntax Directed Translation Scheme $$(SDTS),$$ with non-terminals $$\left\{ {S,A} \right\}$$ and terminals $$\left\{ {A,B} \right\}.$$ $$S \to aA$$ $$\,\,\,\,\,$${ print $$1$$ } $$S \to a$$ $$\,\,\...
Consider the following C program void f(int, short); void main() { int i = 100; short s = 12; short *p = &s; __________ ; // call to f() } Which one of the following expressions, when placed in the blank above, will NOT...
Which one of the following is NOT performed during compilation?
Consider the following translation scheme. $$\eqalign{ & S \to ER \cr & R \to *E\left\{ {pr{\mathop{\rm int}} ('*');} \right\}R\,|\,\varepsilon \cr & E \to F + E\left\{ {pr{\mathop{\rm int}} (' + ');} \right\}\,|\,F \cr...
Consider the following C program: double foo(double); /* Line 1 */ int main () { double da, db; //input da db = foo(da); } double foo(double a){ return a; } The above code compiled without any error or warning. If Line 1...
A common property of logic programming languages and functional languages is:
Which one of the following are essential features of an object-oriented programming language? i) Abstraction and encapsulation ii) Strictly-typedness iii) Type-safe property coupled with sub-type rule iv) Polymorphism in...
Consider the grammar with the following translation rules and E as the start symbol. $$\eqalign{ & E \to {E_1}\# T\,\,\left\{ {E.value = {E_1}.value*T.value} \right\} \cr & \,\,\,\,\,\,\,\,\,\,\,\,\,\,|T\,\,\,\,\,\,\,\,\...
Choose the best matching between the programming style in Group 1 and their characteristics in Group 2 Group 1 P. Functional Q. Logic R. Object-oriented S. Imperative Group 2 1. Command-based, procedural 2. Imperative, a...
Consider the following class definitions in a hypothetical Object Oriented language that supports inheritance and uses dynamic binding. The language should not be assumed to be either Java or C++, though the syntax is si...
Which of the following statements is FALSE?
Which of the following statements is FALSE ?
Consider the translation scheme shown below $$\eqalign{ & S \to TR \cr & R \to + T\left\{ {pr{\mathop{\rm int}} (' + ');} \right\}\,R\,|\,\varepsilon \cr & T \to num\,\left\{ {pr{\mathop{\rm int}} (num.val);} \right\} \c...
In a bottom-up evaluation of a syntax directed definition, inherited attributes can
Type checking is normally done during
A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar. $$\eqalign{ & S \to xxW\,\left\{ {pr{\mathop{\rm int}} \,'1'} \right\} \cr & S \to...
Match the pairs in the following: List - I (A) Small talk (B) LISP (C) Prolog (D) VAL List - II (p) Logic programming (q) Data flow programming (r) Functional programming (s) Object-Oriented programming