SlideShare a Scribd company logo
1 of 26
LR Parsers Canonical Collection LR
LR Parser 1 ,[object Object],[object Object],S T A C K Prg Ejem1 ; Real X2 Fig. 6.2  Aho, Ullman. “Principles of Compiler Design”  pág. 199 Parsing Table eof …
Driver Routine ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Shift ,[object Object],[object Object],[object Object]
Reduce ,[object Object],[object Object],[object Object],[object Object],[object Object]
Accept ,[object Object]
Error ,[object Object]
How to construct a simple LR 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],IBID. Fig. 6.5 pág. 207
How to construct a simple LR 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],IBID. Fig. 6.5 pág. 207
Example: G is a grammar with start symbol E E  E + T E  T T  T/F T  F F  (E) F  id
G’ is the augmented grammar with a new start symbol E’ E’    E E  E + T E  T T  T/F T  F F  (E) F  id Blue nucleous
Closure(E’) E’  ♥E Blue nucleous
Closure(E) E’  ♥E E  ♥ E + T E  ♥ T
Closure(T) E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F
Closure(F) E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id
State 1 E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id
State 2=GoTo(1,E) E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T
State 3 =GoTo(1,T) E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F
State 4=GoTo(1,F) E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥
State 5: from state 1 with ( E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id
State 6:from state1 with id  E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id F  id ♥
States 1,2 ,3,4,5,6 E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id F  id ♥
States 7,8,9 E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id F  id ♥ E’  E+♥T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id T’  T/♥F F  ♥ (E) F  ♥ id F  (E♥) E  E♥+T
States 10,11,12 E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id F  id ♥ E’  E+♥T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id T’  T/♥F F  ♥ (E) F  ♥ id F  (E♥) E  E♥+T E’  E+T♥ T  T ♥ /F T’  T/F♥ F  (E)♥
States 1,2,3,4,... 12 E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id F  id ♥ E’  E+♥T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id T’  T/♥F F  ♥ (E) F  ♥ id F  (E♥) E  E♥+T E’  E+T♥ T  T ♥ /F T’  T/F♥ F  (E)♥
END Canonical Collection LR

More Related Content

Viewers also liked (8)

Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Lecture11 syntax analysis_7
Lecture11 syntax analysis_7Lecture11 syntax analysis_7
Lecture11 syntax analysis_7
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Code generator
Code generatorCode generator
Code generator
 
LALR Parser Presentation ppt
LALR Parser Presentation pptLALR Parser Presentation ppt
LALR Parser Presentation ppt
 
Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow Graphs
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
 
Module 11
Module 11Module 11
Module 11
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

L Rparser Edos

  • 1. LR Parsers Canonical Collection LR
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Example: G is a grammar with start symbol E E  E + T E  T T  T/F T  F F  (E) F  id
  • 11. G’ is the augmented grammar with a new start symbol E’ E’  E E  E + T E  T T  T/F T  F F  (E) F  id Blue nucleous
  • 12. Closure(E’) E’  ♥E Blue nucleous
  • 13. Closure(E) E’  ♥E E  ♥ E + T E  ♥ T
  • 14. Closure(T) E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F
  • 15. Closure(F) E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id
  • 16. State 1 E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id
  • 17. State 2=GoTo(1,E) E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T
  • 18. State 3 =GoTo(1,T) E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F
  • 19. State 4=GoTo(1,F) E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥
  • 20. State 5: from state 1 with ( E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id
  • 21. State 6:from state1 with id E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id F  id ♥
  • 22. States 1,2 ,3,4,5,6 E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id F  id ♥
  • 23. States 7,8,9 E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id F  id ♥ E’  E+♥T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id T’  T/♥F F  ♥ (E) F  ♥ id F  (E♥) E  E♥+T
  • 24. States 10,11,12 E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id F  id ♥ E’  E+♥T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id T’  T/♥F F  ♥ (E) F  ♥ id F  (E♥) E  E♥+T E’  E+T♥ T  T ♥ /F T’  T/F♥ F  (E)♥
  • 25. States 1,2,3,4,... 12 E’  ♥E E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id E’  E♥ E  E♥ + T E’  T♥ T  T♥ /F T  F ♥ F  (♥E) E  ♥ E + T E  ♥ T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id F  id ♥ E’  E+♥T T  ♥ T/F T  ♥ F F  ♥ (E) F  ♥ id T’  T/♥F F  ♥ (E) F  ♥ id F  (E♥) E  E♥+T E’  E+T♥ T  T ♥ /F T’  T/F♥ F  (E)♥