1 / 9

CS 442/542

CS 442/542. Parsing Part 2. Quiz 6 Problems and definitions. Definitions Regular Expression, NFA, DFA, CGF, First Set, Follow Set, First + Problems

kenny
Download Presentation

CS 442/542

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 442/542 Parsing Part 2

  2. Quiz 6 Problems and definitions • Definitions • Regular Expression, NFA, DFA, CGF, First Set, Follow Set, First+ • Problems • Create RE to specify a language, build NFA from RE, build DFA from NFA using the subset construction, build a minimized DFA from a DFA, create and RE that specifies the strings recognized by a DFA. Write simple lex/C code segments

  3. First Set • For any grammar symbol α, First(α) is the set of terminals that can appear at the start of a sentence derived from α

  4. Follow Set • For any nonterminal α, Follow(α) is the set of terminals that can occur immediately α in a sentence

  5. First+ • First+(A ->β ) = { t | if ε ∉ First(β) then t ∈First(β) else t ∈First(β) U Follow(A)} • Also called the Predict set • Note this definition includes ε in the First+ set some definitions exclude it and in the way this set will be used in the algorithm to build the LL(1) parse table ε will not be important

  6. Build First Set

  7. Build the First Sets for the Following Grammar 1. S -> B 2. B -> B1 B2 3. B2 -> OR B1 B2 4. B2 -> ε 5. B1 -> B3 B4 6. B4 -> AND B3 B4 7. B4 -> ε 8. B3 -> VAR

  8. Build Follow Sets

  9. Build LL(1) Parse Table

More Related