SlideShare a Scribd company logo
3
Most read
4
Most read
5
Most read
Transformation From
Left Recursion To
Non-Left Recursion
1
Presented By:
Farzana Aktar
2
Objectives
 To Eliminate Left recursion by rewriting the offending
production.
 The non-terminal A and its productions are said to be left
recursive.
 To replace left recursive by non left recursive production.
3
What is Left Recursion? 4
 A grammar is left-recursive if and only if there exists a nonterminal
symbol that can derive to a sentential form with itself as the leftmost
symbol .
 Symbolically, where indicates the operation of making one or more
substitutions, and is any sequence of terminal and nonterminal
symbols.
 Consider a nonterminal A with two productions
A->A𝜶|β
So, the nonterminal A and its production are said to be left recursive.
Left Recursion’s Formula
 There is a formal technique for eliminating left-recursion from
productions . It’s a direct left recursion.
 Each rule which contains a left-recursive option
A --> Aα|β
 Introduce a new nonterminal A' and rewrite the rule as
A --> βA'
A' --> αA' | ε
5
Working Procedure
 For implementing the code we use C language
 In the code segment, we declare char type variable.
 Here we use sprintf() and strtok() function.
 If we give a non-terminal left recursive expression as an input, then the
recursive value is eliminating.
 Then a non-left recursive expression we get as an output.
6
Code : 7
Output : 8
9

More Related Content

PDF
Operator precedence
PPT
Lecture 1,2
PPTX
CONTEXT FREE GRAMMAR
PPT
Theory of Automata
PPT
Finite automata
PPTX
Lexical analysis - Compiler Design
PPT
Architecture design in software engineering
PPTX
Types of Drivers in JDBC
Operator precedence
Lecture 1,2
CONTEXT FREE GRAMMAR
Theory of Automata
Finite automata
Lexical analysis - Compiler Design
Architecture design in software engineering
Types of Drivers in JDBC

What's hot (20)

PPTX
First and follow set
PPTX
Chomsky Normal Form
PPTX
Syntax Analysis in Compiler Design
PPTX
Context free grammar
PPT
Lecture 3,4
PPTX
Compiler design syntax analysis
PPTX
Theory of automata and formal language
PDF
Types of software testing
PPTX
Deciability (automata presentation)
PPTX
Abstraction and Encapsulation
PDF
Ch3 4 regular expression and grammar
PPTX
Introduction TO Finite Automata
PPTX
Operator precedance parsing
PPTX
Project scheduling and tracking
PPTX
Deadlock dbms
PPTX
LR(1) and SLR(1) parsing
PPT
Software Process Improvement
PPT
Lecture 5
PPTX
RMMM Plan
PPT
Software Engineering (Project Scheduling)
First and follow set
Chomsky Normal Form
Syntax Analysis in Compiler Design
Context free grammar
Lecture 3,4
Compiler design syntax analysis
Theory of automata and formal language
Types of software testing
Deciability (automata presentation)
Abstraction and Encapsulation
Ch3 4 regular expression and grammar
Introduction TO Finite Automata
Operator precedance parsing
Project scheduling and tracking
Deadlock dbms
LR(1) and SLR(1) parsing
Software Process Improvement
Lecture 5
RMMM Plan
Software Engineering (Project Scheduling)
Ad

Recently uploaded (20)

PDF
R24 SURVEYING LAB MANUAL for civil enggi
DOCX
573137875-Attendance-Management-System-original
PPTX
Sustainable Sites - Green Building Construction
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
PPT on Performance Review to get promotions
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Welding lecture in detail for understanding
PPTX
additive manufacturing of ss316l using mig welding
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
UNIT 4 Total Quality Management .pptx
R24 SURVEYING LAB MANUAL for civil enggi
573137875-Attendance-Management-System-original
Sustainable Sites - Green Building Construction
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Embodied AI: Ushering in the Next Era of Intelligent Systems
Foundation to blockchain - A guide to Blockchain Tech
Model Code of Practice - Construction Work - 21102022 .pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
CH1 Production IntroductoryConcepts.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPT on Performance Review to get promotions
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Welding lecture in detail for understanding
additive manufacturing of ss316l using mig welding
Automation-in-Manufacturing-Chapter-Introduction.pdf
UNIT 4 Total Quality Management .pptx
Ad

Left recursion

  • 1. Transformation From Left Recursion To Non-Left Recursion 1
  • 3. Objectives  To Eliminate Left recursion by rewriting the offending production.  The non-terminal A and its productions are said to be left recursive.  To replace left recursive by non left recursive production. 3
  • 4. What is Left Recursion? 4  A grammar is left-recursive if and only if there exists a nonterminal symbol that can derive to a sentential form with itself as the leftmost symbol .  Symbolically, where indicates the operation of making one or more substitutions, and is any sequence of terminal and nonterminal symbols.  Consider a nonterminal A with two productions A->A𝜶|β So, the nonterminal A and its production are said to be left recursive.
  • 5. Left Recursion’s Formula  There is a formal technique for eliminating left-recursion from productions . It’s a direct left recursion.  Each rule which contains a left-recursive option A --> Aα|β  Introduce a new nonterminal A' and rewrite the rule as A --> βA' A' --> αA' | ε 5
  • 6. Working Procedure  For implementing the code we use C language  In the code segment, we declare char type variable.  Here we use sprintf() and strtok() function.  If we give a non-terminal left recursive expression as an input, then the recursive value is eliminating.  Then a non-left recursive expression we get as an output. 6
  • 9. 9