Consider the following LL(1) grammar for a simplified subset of Lisp: P E $$ E

Question:

Consider the following LL(1) grammar for a simplified subset of Lisp:
P → E $$
E → atom
   → ’ E
   → ( E Es )
Es → E Es
   →

(a) What is FIRST(Es)? FOLLOW(E)? PREDICT(Es → ∈)?

(b) Give a parse tree for the string (cdr ‚(a b c)) $$.

(c) Show the left-most derivation of (cdr ‚(a b c)) $$.

(d) Show a trace, in the style of Figure 2.21, of a table-driven top-down parse of this same input.

(e) Now consider a recursive descent parser running on the same input.

At the point where the quote token (’) is matched, which recursive descent routines will be active (i.e., what routines will have a frame on the parser’s run-time stack)?

Figure 2.21:

Parse stack Input stream Comment program read A read B ... initial stack contents predict program stmt list $$ predict stmtJist stmt stmt list stmt list $$ read A read B stmt stmt list $$ read A read B read id stmnt Jist $$ read A read B predict stmt

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: