0% found this document useful (0 votes)
15 views

Compiler

The document discusses different types of recursive grammars including left and right recursion. It provides examples of left recursion rules and how to eliminate left recursion by creating a new grammar using regular expressions. It also discusses finding and handling left factoring in grammars.

Uploaded by

Md. Rohmat Ulla
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Compiler

The document discusses different types of recursive grammars including left and right recursion. It provides examples of left recursion rules and how to eliminate left recursion by creating a new grammar using regular expressions. It also discusses finding and handling left factoring in grammars.

Uploaded by

Md. Rohmat Ulla
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Input = 0,1

States : A,B,C
Start state : A
Sfds

Final term
st
1 class : 09/10/2021
Recursive grammer are two type:
1.left
2.Right
Lift recursive:
A  Aα/ β
Start symbole A
লেফট রিকার্শন হওয়ার কারনঃ স্টাট সিমভ্ল যদি সেইম হয়। A ->
Aα/ β (because of A )
A -> βα* (regular expression)
A()
{
A()
B base case
}
Right recursive
A  αA/β
A ->α*β(regular expression)
A()
{
B base case
A()
}
Elimination left recursion:
A  Aα/ β
For this grammar, regular expression is : A  βα*
We want eliminate left recursive. For this We had to
make new grammar using regular expression.
So,
A  βα*
(βα* means: β, βα, βαα……..
new grammar:
A βA’
A’ ε/α*
If we want to make regular expression using this
grammar it will make same.
A  βα* As A’  ε/α*
Find left factoring
S α/αβ1/ αβ2/ αβ3
In this grammar, if we want get S  αβ3
What will happen,

But, we want αβ3. So, it should backtrack. For this kind


problem we should create new grammer.
Find left factoring and handle that in proper way:
S α/αβ1/ αβ2/ αβ3
New grammar:
S αS’
S’ ε/β1/β2/ β3

Terminal letter  small letter

Microprocessor lab
Compiler
Python
Lexical analysis

You might also like