Context Free Grammar
A Context Free Grammar(CFG) is defined as G=(V,T,P,S) where
V=Finite set of Variables
T=Finite set of Terminals
S→aSb|𝟄 is a grammar which accepts the language contains equal number of a's and equal number of b's
similarly
S→aSa|bSb|𝟄 is grammar which generates even length plaindrome
S→aSa|bSb is grammar which generates odd length palindrome
A Context Free Grammar(CFG) is defined as G=(V,T,P,S) where
V=Finite set of Variables
T=Finite set of Terminals
P=Production rule which can be defined as 𝝰→𝛃 where 𝝰𝟄V and 𝞫→(V U T)*
S is a starting production
Example:
S→aSb|𝟄 is a grammar which accepts the language contains equal number of a's and equal number of b's
similarly
S→aSa|bSb|𝟄 is grammar which generates even length plaindrome
S→aSa|bSb is grammar which generates odd length palindrome
No comments:
Post a Comment