The GATE Grind

GATE 2020 CS – Question 34

Compiler Design · Parsing and Syntax Analysis · 1 mark · Numerical answer

Consider the following grammar.

$S\to aSB\mid d$

$B\to b$

The number of reduction steps taken by a bottom-up parser while accepting the string $aaadbbb$ is ______.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 7 to 7

Explanation

The reductions are: $d\to S$ (1), $b\to B$ three times (3), and $aSB\to S$ three times (3). Total 7.