SlideShare a Scribd company logo
1 of 9
BIRLA INSTITUTE OF TECHNOLOGY
MESRA (JAIPUR CAMPUS)
Compiler Design(CA513)
Shift Reduce Parser
Submitted By –
Samyak Jain (MCA/25014/22)
Abhishek Ahlawat (MCA/25017/22)
Submitted To –
Madhvi Sinha Mam
What is Shift Reduce Parser?
• Shift Reduce Parser is a type of Bottom-Up Parser. It
generates the Parse Tree from Leaves to the Root.
• In Shift Reduce Parser, the input string will be reduced to the
starting symbol.
• This parser requires two data structure i.e
 An input buffer for storing the input string.
 A stack for storing and accessing the production rules.
Basic Operations
• Shift :- the current symbol in the input string is pushed to a
stack.
• Reduce :- the symbol in RHS of production rule is replaced by
non-terminal.
• Accept :- if only the start symbol is present in the stack and
input buffer is empty then , the parsing action is called accept.
• Error :- this is the situation in which the parser can neither
perform shift action nor reduce action and not even accept
action.
Working
Initially , shift reduce parser is present in the following configuration:
• Stack contain only the $ symbol.
• Input buffer contains the input string with $ at its end.
The parser keeps on repeating this cycle until-
•An error is detected.
•Or stack is left with only the start symbol and the input buffer becomes empty.
After achieving this configuration,
•The parser halts.
•It reports the successful completion of parsing.
Example 1
Consider the following grammar-
E → E + E
E → a
E → b
Parse the input string a+b
Example 2
Consider the following grammar-
E → E – E
E → E x E
E → id
Parse the input string id – id x id
References
• https://www.geeksforgeeks.org/shift-reduce-parser-compiler/
• https://www.tutorialspoint.com/what-is-shift-reduce-parser
• https://www.gatevidyalay.com/shift-reduce-
parsing/#:~:text=In%20compiler%20design%2C%20Shift%2DReduce,imple
mentation%2D%20Stack%20and%20Input%20buffer.
Thank You

More Related Content

Similar to Compiler Design PPT.pptx

Oracle Database 12c features for DBA
Oracle Database 12c features for DBAOracle Database 12c features for DBA
Oracle Database 12c features for DBA
Karan Kukreja
 
ITSP PAL Training - Advanced
ITSP PAL Training - AdvancedITSP PAL Training - Advanced
ITSP PAL Training - Advanced
Rick Youngblood
 
Is accurate system-level power measurement challenging? Check this out!
Is accurate system-level power measurement challenging? Check this out!Is accurate system-level power measurement challenging? Check this out!
Is accurate system-level power measurement challenging? Check this out!
Deepak Shankar
 
Jboss World 2011 Infinispan
Jboss World 2011 InfinispanJboss World 2011 Infinispan
Jboss World 2011 Infinispan
cbo_
 
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...
Spark Summit
 
Oracle Course
Oracle CourseOracle Course
Oracle Course
rspaike
 

Similar to Compiler Design PPT.pptx (20)

Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
 
PostgreSQL and Benchmarks
PostgreSQL and BenchmarksPostgreSQL and Benchmarks
PostgreSQL and Benchmarks
 
Dan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New FeaturesDan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New Features
 
Sloupcové uložení dat a použití in-memory technologií u řešení Exadata
Sloupcové uložení dat a použití in-memory technologií u řešení ExadataSloupcové uložení dat a použití in-memory technologií u řešení Exadata
Sloupcové uložení dat a použití in-memory technologií u řešení Exadata
 
Control hazards MIPS pipeline.pptx
Control hazards MIPS pipeline.pptxControl hazards MIPS pipeline.pptx
Control hazards MIPS pipeline.pptx
 
Oracle Database 12c features for DBA
Oracle Database 12c features for DBAOracle Database 12c features for DBA
Oracle Database 12c features for DBA
 
Sap abap
Sap abapSap abap
Sap abap
 
Compiler unit 2&3
Compiler unit 2&3Compiler unit 2&3
Compiler unit 2&3
 
ITSP PAL Training - Advanced
ITSP PAL Training - AdvancedITSP PAL Training - Advanced
ITSP PAL Training - Advanced
 
Is accurate system-level power measurement challenging? Check this out!
Is accurate system-level power measurement challenging? Check this out!Is accurate system-level power measurement challenging? Check this out!
Is accurate system-level power measurement challenging? Check this out!
 
Query processing and Query Optimization
Query processing and Query OptimizationQuery processing and Query Optimization
Query processing and Query Optimization
 
Query processing and Query Optimization
Query processing and Query OptimizationQuery processing and Query Optimization
Query processing and Query Optimization
 
Jboss World 2011 Infinispan
Jboss World 2011 InfinispanJboss World 2011 Infinispan
Jboss World 2011 Infinispan
 
Understanding printed board assembly using simulation with design of experime...
Understanding printed board assembly using simulation with design of experime...Understanding printed board assembly using simulation with design of experime...
Understanding printed board assembly using simulation with design of experime...
 
Design and Implementation of an Efficient Carry Skip Adder
Design and Implementation of an Efficient Carry Skip AdderDesign and Implementation of an Efficient Carry Skip Adder
Design and Implementation of an Efficient Carry Skip Adder
 
Nilanjan RESUME updated
Nilanjan RESUME updatedNilanjan RESUME updated
Nilanjan RESUME updated
 
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...
Cost-Based Optimizer Framework for Spark SQL: Spark Summit East talk by Ron H...
 
Oracle Course
Oracle CourseOracle Course
Oracle Course
 
IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...
IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...
IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...
 
Apache Apex Fault Tolerance and Processing Semantics
Apache Apex Fault Tolerance and Processing SemanticsApache Apex Fault Tolerance and Processing Semantics
Apache Apex Fault Tolerance and Processing Semantics
 

More from SamyakJain710491 (11)

Bayesian Belief Network and its Applications.pptx
Bayesian Belief Network and its Applications.pptxBayesian Belief Network and its Applications.pptx
Bayesian Belief Network and its Applications.pptx
 
performance appraisal at Tech Mahindra.pptx
performance appraisal at Tech Mahindra.pptxperformance appraisal at Tech Mahindra.pptx
performance appraisal at Tech Mahindra.pptx
 
Process Based Estimation.pptx
Process Based Estimation.pptxProcess Based Estimation.pptx
Process Based Estimation.pptx
 
Internet Protocol(Samyak Jain 25014).pptx
Internet Protocol(Samyak Jain 25014).pptxInternet Protocol(Samyak Jain 25014).pptx
Internet Protocol(Samyak Jain 25014).pptx
 
Equivalence of DFAs and NFAs.pptx
Equivalence of DFAs and NFAs.pptxEquivalence of DFAs and NFAs.pptx
Equivalence of DFAs and NFAs.pptx
 
Binomial_Coefficient_and_World_series_problem_using_Dynamic_Programming.pptx
Binomial_Coefficient_and_World_series_problem_using_Dynamic_Programming.pptxBinomial_Coefficient_and_World_series_problem_using_Dynamic_Programming.pptx
Binomial_Coefficient_and_World_series_problem_using_Dynamic_Programming.pptx
 
Cache Coherence.pptx
Cache Coherence.pptxCache Coherence.pptx
Cache Coherence.pptx
 
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptxVALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
 
SWING.pptx
SWING.pptxSWING.pptx
SWING.pptx
 
AVL tree PPT.pptx
AVL tree PPT.pptxAVL tree PPT.pptx
AVL tree PPT.pptx
 
Process and Thread Management in Solaris Operating System.pptx
Process and Thread Management in Solaris Operating System.pptxProcess and Thread Management in Solaris Operating System.pptx
Process and Thread Management in Solaris Operating System.pptx
 

Recently uploaded

SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 

Recently uploaded (20)

Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 

Compiler Design PPT.pptx

  • 1. BIRLA INSTITUTE OF TECHNOLOGY MESRA (JAIPUR CAMPUS) Compiler Design(CA513) Shift Reduce Parser Submitted By – Samyak Jain (MCA/25014/22) Abhishek Ahlawat (MCA/25017/22) Submitted To – Madhvi Sinha Mam
  • 2. What is Shift Reduce Parser? • Shift Reduce Parser is a type of Bottom-Up Parser. It generates the Parse Tree from Leaves to the Root. • In Shift Reduce Parser, the input string will be reduced to the starting symbol. • This parser requires two data structure i.e  An input buffer for storing the input string.  A stack for storing and accessing the production rules.
  • 3. Basic Operations • Shift :- the current symbol in the input string is pushed to a stack. • Reduce :- the symbol in RHS of production rule is replaced by non-terminal. • Accept :- if only the start symbol is present in the stack and input buffer is empty then , the parsing action is called accept. • Error :- this is the situation in which the parser can neither perform shift action nor reduce action and not even accept action.
  • 4. Working Initially , shift reduce parser is present in the following configuration: • Stack contain only the $ symbol. • Input buffer contains the input string with $ at its end.
  • 5. The parser keeps on repeating this cycle until- •An error is detected. •Or stack is left with only the start symbol and the input buffer becomes empty. After achieving this configuration, •The parser halts. •It reports the successful completion of parsing.
  • 6. Example 1 Consider the following grammar- E → E + E E → a E → b Parse the input string a+b
  • 7. Example 2 Consider the following grammar- E → E – E E → E x E E → id Parse the input string id – id x id
  • 8. References • https://www.geeksforgeeks.org/shift-reduce-parser-compiler/ • https://www.tutorialspoint.com/what-is-shift-reduce-parser • https://www.gatevidyalay.com/shift-reduce- parsing/#:~:text=In%20compiler%20design%2C%20Shift%2DReduce,imple mentation%2D%20Stack%20and%20Input%20buffer.