Context Free Grammer
Context Free Grammer
1 Introduction
2 Components of CFG
3 Examples of CFG
4 Derivation in CFG
5 Parse Trees
6 Conclusion
E →E +T |T
T →T ∗F |F
F → (E ) | id
Explanation:
E : Expression
T : Term
F : Factor
id: Represents identifiers (e.g., variables or numbers).
S → (S) | SS | ε
Explanation:
S: Start symbol.
ε: Represents the empty string.
This grammar generates strings like (), (()), ()(), etc.
S → aSa | bSb | a | b | ε
Explanation:
S: Start symbol.
This grammar generates palindromes like a, aba, abba, etc.
S → aSb | ab
S ⇒ aSb ⇒ aabb
a S b
a S b
ε
Dr. Mayank Kumar Jain (Amity University Rajasthan,Context-Free
Jaipur) Grammar (CFG) February 18, 2025 9 / 10
Conclusion