In Fig. 4.56 is a grammar for certain statements, similar to that discussed in Exercise XXXXXXXXXXAgain, e and s are terminals standing for conditional expressions and "other statements,"...


In Fig. 4.56 is a grammar for certain statements, similar to that discussed in Exercise 4.4.12. Again, e and s are terminals standing for conditional expressions and "other statements," respectively.

a) Build an LR parsing table for this grammar, resolving conflicts in the usual way for the dangling-else problem.

b) Implement error correction by filling in the blank entries in the parsing table with extra reduce-actions or suitable error-recovery routines.


c) Show the behavior of your parser on the following inputs:


(i) if e the n s ; if e the n s end


(ii) while e do begin s ; if e the n s ; end


Exercise 4.4.12


In Fig. 4.24 is a grammar for certain statements. You may take e and s to be terminals standing for conditional expressions and "other statements," respectively. If we resolve the conflict regarding expansion of the optional "else" (nonterminal stmtTail) by preferring to consume an else from the input whenever we see one, we can build a predictive parser for this grammar. Using the idea of synchronizing symbols described in Section 4.4.5: a) Build an error-correcting predictive parsing table for the grammar. b) Show the behavior of your parser on the following inputs:


(i) if e the n s ; if e the n s end

( M ) whil e e do begin s ; if e the n s ; end


Fig. 4.24


Fig. 4.56



May 22, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here