FAFL Final Lecture 26.1 CMH
FAFL Final Lecture 26.1 CMH
Lecture 26.1
Substitution, Removal of useless and Left
Recursion
S c h o o l o f C o m p u t i n g a n d I n f o r m a t i o n Te c h n o l o g y
Chaithra M H
AY:2020-2021
OUTLINE
Lecture Discussion
Aa Aa
A aaA A aaA
B abbA A abbA
B b
A SUBSTITUTION - RULE
In general
AxBz
B y1 | y2 |. . . . . | yn
Substitute
Equivalent
A x y1 z | x y2 z|. . . . . | x yn z grammar
A SUBSTITUTION RULE
Example-1
Consider the productions and simplify the grammar by substitution method :
AaBa
Bab|b
such that A + Aα , if the first symbol on RHS in a sentential form is a variable and if
the derivation is obtained from the same non-terminal then grammar is having left
recursion.
Definition :
A symbol can be useless if it does not appear on the right-hand side of the
production rule and does not take part in the derivation of any string is known as a
useless symbol.
A variable can be useless if it does not take part in the derivation of any string,
variable is known as a useless variable.
So we could see that Symbol B and C are useless symbol, remove them (whole
production in which it contains):
S a
Ab
Definition of
Definition of Left
Substitution with Useless
recursion with
examples productions with
examples
examples
DISCUSSION
5 MINUTES
THANK YOU