Time Left - 10:00 mins
GATE CS 2018 - Compiler Design Quiz- 4 (Syntax Directed Translation)
Attempt now to get your rank among 483 students!
Question 1
Consider the following Syntax Directed Translation Scheme (SDTS), with non-terminals {S, A} and terminals {a, b}.
Using the above SDTS, the output printed by a bottom-up parser, for the input aab is:
Using the above SDTS, the output printed by a bottom-up parser, for the input aab is:
Question 2
CSG can be defined by .
Question 3
Consider the given SDT which will be executed in connection with a bottom-up parser. For the input babbba, what will be the final output?
S →aS { print “x”}
S →bS { print “y”}
S →a { print “z”}
S →b { print “z”}
S →aS { print “x”}
S →bS { print “y”}
S →a { print “z”}
S →b { print “z”}
Question 4
Identify the type of error (earliest phase) identified during compilation of the following program.
#include<stdio.h>
main()
{
int gate, exam, rank;
gate= exam= rank=10.3;
printf (“ %c”, gate);
}
#include<stdio.h>
main()
{
int gate, exam, rank;
gate= exam= rank=10.3;
printf (“ %c”, gate);
}
Question 5
Consider the syntax directed translation scheme (SDTS) given in the following. Assume attribute evaluation with bottom-up parsing, i.e., attributes are evaluated immediate ly after a reduction.
E→ E11 * T {E.val = E11.val * T.val}
E→ T {E.val = T.val}
T→ F - T11 {T.val = F.val - T11.val}
T→ F {T.val = F.val}
F→2 {F.val = 2}
F→4 {F.val = 4}
Using this SDTS, for the expression 4 – 2 – 4 * 2 compute its E.val.
- 483 attempts
- 4 upvotes
- 10 comments
Apr 10GATE & PSU CS