Computer Sciences > GATE 2021 SET-1 > Syntax Directed Translation
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 -> DE
D -> int ID {record that ID.lexeme is of type int}
D -> bool ID {record that ID.lexeme is of type bool}
E -> E1 + E2 {check that E1.type = E2.type = int; set E.type:= int}
E ->!E1 {check that E1.type = bool; set E.type:= bool}
E -> ID {set E.type:= int}
With respect to the above grammar, which one of the following choices is correct?
A
The actions can be used to correctly type-check any syntactically correct program.
B
The actions can be used to type-check syntactically correct integer variable declarations and integer expressions.
C
The actions can be used to type-check syntactically correct boolean variable declarations and boolean expressions.
D
The actions will lead to an infinite loop.

Correct : b

Similar Questions

Given the following syntax directed translation rules:Rule 1: R→AB {B.i = R.i1; A.i=B.i; R.i=A.i+1;}Rule 2: P→CD {P.i = C.i+D.i; D.i=C.i+2;}Rule 3: Q&...
#1430 MCQ
A palindrome is a word that reads the same forwards and backwards. In a game of words, a player has the following two plates painted with letters. From...
#1 MCQ
Which number does not belong in the series below? 2, 5, 10, 17, 26, 37, 50, 64
#4 MCQ

Related Topics

No tags found

Unique Visitor Count

Total Unique Visitors

Loading......