number of reductions is nothing but the number of non-leaves in the parse tree ...

The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

+11 votes

Consider the syntax directed translation scheme (SDTS) given in the following. Assume attribute evaluation with bottom-up parsing, i.e., attributes are evaluated immediately after a reduction.

E$\rightarrow $ E$_{1}$ * T {E.val = E$_{1}$.val * T.val}

E$\rightarrow $ T {E.val = T.val}

T$\rightarrow $ F - T$_{1}$ {T.val = F.val - T$_{1}$.val}

T$\rightarrow$ F {T.val = F.val}

F$\rightarrow$2 {F.val = 2}

F$\rightarrow$4 {F.val = 4}

- Using this SDTS, construct a parse tree for the expression $4 - 2 - 4 * 2$ and also compute its $E.val$.
- It is required to compute the total number of reductions performed to parse a given input. Using synthesized attributes only, modify the SDTS given, without changing the grammar, to find $E.red$, the number of reductions performed while reducing an input to $E$.

- All categories
- General Aptitude 1.3k
- Engineering Mathematics 5.2k
- Digital Logic 2k
- Programming & DS 3.7k
- Algorithms 3.2k
- Theory of Computation 4k
- Compiler Design 1.6k
- Databases 3k
- CO & Architecture 2.6k
- Computer Networks 3k
- Non GATE 1k
- Others 1.3k
- Admissions 486
- Exam Queries 435
- Tier 1 Placement Questions 18
- Job Queries 56
- Projects 9

36,171 questions

43,624 answers

124,025 comments

42,893 users