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.2k
- Engineering Mathematics 4.8k
- Digital Logic 2k
- Programming & DS 3.5k
- Algorithms 3k
- Theory of Computation 3.8k
- Compiler Design 1.5k
- Databases 2.8k
- CO & Architecture 2.5k
- Computer Networks 2.9k
- Non GATE 940
- Others 1.2k
- Admissions 320
- Exam Queries 409
- Tier 1 Placement Questions 17
- Job Queries 52
- Projects 8

34,170 questions

40,846 answers

115,882 comments

39,704 users