SLIDE 1
CS453 ¡Spring ¡12 ¡Quiz ¡1 ¡ Regular ¡Expressions ¡and ¡Finite ¡State ¡Machines ¡ ¡
- 1. ¡Build ¡an ¡NFA ¡for ¡BoolLits ¡and ¡intLits, ¡given ¡the ¡following ¡regular ¡definitions: ¡
¡ ¡ ¡ ¡ ¡ ¡ ¡ dig ¡: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡[0-‑9] ¡ BoolDig: ¡ ¡ ¡[01] ¡ BoolLit ¡: ¡ ¡ ¡BoolDig+ ¡ ¡ intLit ¡: ¡ ¡ ¡ ¡ ¡ ¡ ¡dig+ ¡ ¡ Priority: ¡if ¡a ¡literal ¡consists ¡of ¡0-‑s ¡and ¡1-‑s ¡only, ¡it ¡is ¡a ¡BoolLit ¡ ¡ ¡
- 2. ¡Now ¡transform ¡the ¡NFA ¡to ¡a ¡DFA ¡
¡
CS453 ¡Spring ¡12 ¡Quiz ¡2 ¡ Predictive ¡Parsing ¡ ¡
- 1. ¡ ¡Given ¡an ¡augmented, ¡grammar ¡for ¡statements: ¡
¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡P ¡à ¡{ ¡L ¡} ¡$ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡L ¡à ¡S ¡ ¡L ¡| ¡ε ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡S ¡à ¡if ¡ ¡t ¡{ ¡L ¡} ¡| ¡while ¡t ¡{ ¡L ¡} ¡| ¡id ¡= ¡num ¡; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ where ¡P ¡stands ¡for ¡program, ¡L ¡for ¡list ¡ ¡of ¡ ¡statements, ¡and ¡S ¡stands ¡for ¡statement ¡ ¡ a) ¡Produce ¡NULLABLE, ¡FIRST, ¡and ¡FOLLOW ¡ ¡ b) ¡Produce ¡the ¡predictive ¡parse ¡table. ¡ ¡ c) ¡Show ¡the ¡parse ¡tree ¡obtained ¡by ¡predictive ¡parsing: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡{ ¡while ¡t ¡{ ¡ ¡if ¡ ¡t ¡ ¡{ ¡ ¡id ¡= ¡num ¡; ¡id ¡= ¡num ¡; ¡} ¡} ¡}$ ¡ ¡
CS453 ¡Spring ¡12 ¡Quiz ¡3 ¡ LR(0) ¡ ¡Parsing ¡
- 1. ¡ ¡Given ¡an ¡augmented, ¡grammar ¡for ¡single ¡bracket ¡nests: ¡