Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Successfully reported this slideshow.

Like this presentation? Why not share!

- Left factor put by siet_pradeep18 788 views
- Program to remove Left factoring by Shraddha Patel 4334 views
- Cs419 lec8 top-down parsing by Arab Open Univers... 2008 views
- Top down and botttom up Parsing by Gerwin Ocsena 39123 views
- Recursive descent parsing by Boy Baukema 2113 views
- Follow up table talk march 18 by Jeremy 1124 views

No Downloads

Total views

10,841

On SlideShare

0

From Embeds

0

Number of Embeds

11

Shares

0

Downloads

324

Comments

0

Likes

9

No embeds

No notes for slide

- 1. WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Computer Science Department dr.sharaf@from-masr.com
- 2. Dr. Hussien M. Sharaf TOP-DOWN PARSING A parser is a top-down if it discovers a parse tree top to bottom. A top-down parse corresponds to a preorder traversal of the parse tree. A left most derivation is applied to each step.
- 3. Dr. Hussien M. Sharaf LL PARSING LL parsing is a technique of top-down parsing. Consists of: Parser stack: that holds grammar symbols: non-terminals and tokens. Parsing table: that specifies the parser actions (Match, Predict, Accept, Error). Driver function: that interacts with parser stack, parsing table, and scanner. Scanner Next token Parser driver Parsing table Output Parsing stack
- 4. Dr. Hussien M. Sharaf PROBLEMS FACING LL(1) PARSERS 1. 2. Left recursion. Left factoring. Both problems prevents any LL parser from deciding deterministically which rule should be fired.
- 5. Dr. Hussien M. Sharaf LEFT RECURSION We have to eliminate left recursion because top down parsing methods can not handle left recursive grammars. A grammar is left recursive if it has a nonterminal A such that there is a derivation A Aα for some string α Consider the left recursive grammar A A α1 | A α2 | β1 | β2 +
- 6. Dr. Hussien M. Sharaf REMOVE LEFT RECURSION 1. 2. 3. Let A other productions of A not starting with A (i.e. β1, β2), followed by A′ (A β1A′| β2A′) Then let A′ postfix of the productions starting with A (α1, α2) followed by A′ (A′ α1A′|α2A′) Then add |ε to A′ (A′ α1A′|α2A′| ε) +
- 7. Dr. Hussien M. Sharaf ELIMINATION OF LEFT RECURSION EXAMPLE E E+T|T T T*F|F F (E)|id The equivalent non-left recursive grammar is: E T E′ E′ +TE′|ε T FT′ T′ *FT′|ε F (E) | id
- 8. Dr. Hussien M. Sharaf LEFT FACTORING In left factoring it is not clear which of two alternative productions to use to expand a nonterminal A. i.e. if A αβ1 | αβ2 W e don’t know whether to expand A to αβ1 or to αβ2 To remove left factoring for this grammar replace all A productions containing α as prefix by A αA′ then A′ β1 | β2
- 9. Dr. Hussien M. Sharaf ELIMINATION OF LEFT FACTORING EXAMPLE S iEtS | iEtSeS | a Eb The equivalent non-left factored grammar is: S iEtSS′ | a S′ eS | ε Eb
- 10. Dr. Hussien M. Sharaf THANK YOU

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment