When an Empty Production Is Legal

A predictive parser uses this grammar, with start symbol SS and an external end-of-input marker called EOF:


S→E∣(E)E→idRR→+idR∣ε.\begin{aligned} S &\to E \mid (E) \\ E &\to \mathrm{id}R \\ R &\to +\mathrm{id}R \mid \varepsilon. \end{aligned}


Complete the decision table for a call to RR. Enter exactly continue for R→+idRR \to +\mathrm{id}R, empty for R→εR \to \varepsilon, or error when neither production is valid for the lookahead token.

Lookahead tokenDecision for R
+
)
EOF
id

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Parsing Questions: