Session 9: �Greibach Normal form (GNF)
By
Dr. Ashok Kumar
Amity School of Engineering & Technology
Greinbach Normal Form
2
All productions have form:
symbol
variables
Amity School of Engineering & Technology
Conversion from CFG to GNF
A CFG(context free grammar) is in GNF(Greibach normal form) if all the production rules satisfy one of the following conditions:
For example:
G1 = {S → aAB | aB, A → aA| a, B → bB | b}
G2 = {S → aAB | aB, A → aA | ε, B → bB | ε}
The production rules of Grammar G1 satisfy the rules specified for GNF, so the grammar G1 is in GNF. However, the production rule of Grammar G2 does not satisfy the rules specified for GNF as A → ε and B → ε contains ε(only start symbol can generate ε). So the grammar G2 is not in GNF.
Amity School of Engineering & Technology
4
Examples:
Greinbach
Normal Form
Not Greinbach
Normal Form
Amity School of Engineering & Technology
5
Greinbach
Normal Form
Amity School of Engineering & Technology
6
Observations
for parsing
form of any context-free grammar
Amity School of Engineering & Technology