1 / 16

Top-Down parsing

Top-Down parsing. LL(1) parsing. Overview of Top-Down. There are only two actions Replace Match. Overview of Top-Down. e.g. with grammar. LL(k) parsing. L stands for left-to-right parse of input L stands for leftmost-derivation k stands for k-token look-ahead. LL(1) Parsing.

Download Presentation

Top-Down parsing

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. Top-Down parsing LL(1) parsing

  2. Overview of Top-Down • There are only two actions • Replace • Match

  3. Overview of Top-Down • e.g. with grammar

  4. LL(k) parsing • L stands for left-to-right parse of input • L stands for leftmost-derivation • k stands for k-token look-ahead

  5. LL(1) Parsing • At top of Parsing stack • For Non-terminal • Replace: a decision must be made, based on the current input token. • For terminal • Match: no decision is to be made but need to see if it is the same as the current input token, if not, an error occurs.

  6. LL(1) Parsing : First Sets • First Sets • Let X be a grammar symbol (a terminal or non-terminal) or ε. Then the set First(X) consisting of terminals, and possibly ε, is defined as follows

  7. LL(1) Parsing : First Sets • e.g. for the grammar

  8. LL(1) Parsing : Follow Sets • Follow Sets • Given a non-terminal A, the set Follow(A), consisting of terminals, and possibly $, is defined as follows. • ε is never an element of Follow set

  9. LL(1) Parsing : Follow Sets • e.g. for the grammar

  10. First & Follow set

  11. LL(1) Parsing table • How to construct LL(1) parsing table

  12. LL(1) Parsing table

  13. LL(1) Parsing table

  14. LL(1) grammar • A grammar is LL(1) if the following conditions are satisfied. • That is the LL(1) parsing table has at most one production in each table entry.

  15. Mentioned issues • Left Recursion removal • Left Factoring

  16. References • COMPILER CONSTRUCTION: Principles and Practice, • Kenneth C. Louden • Chapter 4 • http://www.cs.sjsu.edu/faculty/louden/cmptext/ • http://www.course.com/isbn=0-534-93972-4

More Related