- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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,
A → Ba
B → Ba|Bb|e
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 −
bn ⇒ A→bA|b A is on right side bm ⇒ 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,
bn ⇒ A→Ab|b bm ⇒ B→Bb|b
The complete expression grammar is as follows −
S→AaBa A→Ab|b B→Bb|b
Advertisements