# Explain about right linear regular grammars in TOC

Data Structure AlgorithmsComputer ScienceComputers

Regular grammar describes a regular language. It consists of four components, which are as follows −

G = (N, E, P, S)

Where,

• N − finite set of non-terminal symbols,

• E − a finite set of terminal symbols,

• P − a set of production rules, each of one is in the forms

• S → aB

• S → a

• S → ∈,

• S ∈ N is the start symbol.

The above grammar can be of two forms −

• Right Linear Regular Grammar

• Left Linear Regular Grammar

## Linear Grammar

When the right side of the Grammar part has only one terminal then it's linear else non linear.

Let’s discuss about right linear grammar −

## Right linear grammar

Right linear grammar means that the non-terminal symbol will be at the right side of the production.

It is a formal grammar (N, Σ, P, S) such that all the production rules in P are of one of the following forms −

L → a, { L is a non-terminal and a is a terminal in Σ}
L → aM, {L and M are non-terminals in N and a is in Σ}
L → ∈.

### Example

Consider a language L= {bnabma | n>=2, m>=2}

The production rules or grammar for the given language L= {bnabma | n>=2, m>=2} is −

S→bbB    ⇒for first 2 b’s
B→bB|aC  ⇒ any number of b’s followed by a
C→bbD    ⇒ 2b’s
D→ bD|a  ⇒ any number of b’s followed by a