FOR FREE YEAR SOLVED

Linear Grammar

 

Linear Grammar:

 

Another restriction form of Context Free Grammar is called linear grammar where right hand side of all productions has a maximum of one non-terminal or variable.

 

Production of linear grammar:

 

V → T* | T*V | VT* | T* VT*         [At most a variable or non-terminal allowed]

 

Example:

 

 

The above grammar is CFG and as well as linear grammar because it follows the production rule of the linear grammar (V → T* | T* V | VT* | T* VT*).

 

Another example:

 

 

The above grammar is CFG but not linear grammar because one of the production S → aAB contains more than one non-terminal or variable which violates the production rule of the linear grammar (V → T* | T* V | VT* | T* VT*).

 

Even the above-stated grammar is S-grammar. (For details follow Simple Grammar)

 

Linear grammar has two types:

 

1. Left Linear Grammar: A linear grammar is called left linear if the right hand side non-terminal or variable in each production are at the left end.

 

Regular grammar has the same production rule (For details follow chapter Types of Grammar)        

 

Example:

 

 

2. Right Linear Grammar: A linear grammar is called right linear if the right hand side non-terminal or variable in each production are at the right end.

 

Regular grammar has the same production rule  (For details follow chapter Types of Grammar)

 

Example:

 

For every left linear grammar there exist a right linear grammar or vice versa.