Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
How to convert right linear grammar to left linear grammar?
For every finite automata (FA) there exists a regular grammar and for every regular grammar there is a left linear and right linear regular grammar.
Example 1
Consider a regular grammar −
a(a+b)* A → aB B → aB|bB|e
For the given regular expression, the above grammar is right linear grammar.
Now, convert the above right linear grammar to left linear grammar.
The rule to follow for conversion is,
Finite Automata → Right linear
The reverse of right linear →left linear grammar.
So,
<p>A → Ba</p><p>B → Ba|Bb|e</p>
Finally for every right linear there is a
Example
Consider a language {bnabma| n>=2, m>=2}
The right linear grammar for the given language is −
b<sup>n</sup> ⇒ A→bA|b A is on right side b<sup>m</sup> ⇒ B→bB|b B is on right side
The complete expression grammar is −
S→AaBa A→bA|b B→bB|b.
The left grammar for the above right linear grammar is,
b<sup>n</sup> ⇒ A→Ab|b b<sup>m</sup> ⇒ B→Bb|b
The complete expression grammar is as follows −
S→AaBa A→Ab|b B→Bb|b
