Download presentation
Presentation is loading. Please wait.
1
Top-Down parsing LL(1) parsing
2
Overview of Top-Down There are only two actions 1.Replace 2.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 Non-terminalnullableFirstFollow SYes($, )
11
LL(1) Parsing table How to construct LL(1) parsing table
12
LL(1) Parsing table M[N,T]()$ S(S)Sεε
13
LL(1) Parsing table M[N,T]()$ S(S)Sεε
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/cm ptext/ http://www.cs.sjsu.edu/faculty/louden/cm ptext/ http://www.cs.sjsu.edu/faculty/louden/cm ptext/ http://www.course.com/isbn=0-534- 93972-4 http://www.course.com/isbn=0-534- 93972-4 http://www.course.com/isbn=0-534- 93972-4
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.