Skip to content
Official PYQ · 2005

GATE CS 2005 Q83b — Parsing (LL, LR)

Explain with AI

Consider the following expression grammar. The semantic rules for expression evaluation are stated next to each grammar production.E→numberE.val=number.val∣ E  ‘+’ EE(1).val=E(2).val+E(3).val∣ E  ‘×’ EE(1).val=E(2).val×E(3).val\begin{array}{l|l} E\rightarrow number & E.val = {number.val} \\\qquad \mid \ E \ \ ‘+\text{'} \ E & E^{(1)}.val = E^{(2)}.val + E^{(3)}.val \\\qquad \mid \ E \ \ ‘\times\text{'} \ E & E^{(1)}.val = E^{(2)}.val \times E^{(3)}.val \end{array}

Assume the conflicts of this question are resolved using yacc tool and an LALR(1) parser is generated for parsing arithmetic expressions as per the given grammar. Consider an expression 3×2+13 \times 2 + 1. What precedence and associativity properties does the generated parser realize?

Choose one option
View answer

Answer: B

Worked explanation not available yet.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Parsing (LL, LR) questions