TA: Jade Cheng (TA) ICS 313 HW 8 Problem set on p.198, nos. 4, 5 Due 2/17/19 [Exercise 4] Show a trace of the recursive descent parse given in Section 4.4.1 for the string a * (b + c). Grammar: --> { (+|-) } --> { (*|\) } --> id | Solution: call lex // return a enter enter enter call lex // return * exit call lex // return ( enter call lex // return b enter enter enter call lex // return + exit exit call lex // return c enter enter call lex // return ) exit exit exit call lex // return EOF exit exit exit [Exercise 5] Given the following grammar and the right sentential form, draw a parse tree and show the phrases and simple phrases, as well as the handle. Grammar: S --> aAb | bBA A --> ab | aAB B --> aB |b a. aaAbb Parse Tree: S / | \ a A b /|\ a A B | b Handles: b, aAB Phrases: aaAbb, aaABb, aAb Simple Phrase: b b. bBab Parse Tree: S / | \ b B A / \ a b Handles: ab Phrases: bBab, bBA Simple Phrase: ab c. aaAbBb aaAbBb --> aSBb --> aSBB --> x or aaAbBb--> aaAbBB --> aSBB --> x Therefore the last string can not be derived from the given grammar.