🔤 FIRST & FOLLOW Calculator
15 Grammar Examples • Step-by-Step • Animated Learning
📖 FIRST and FOLLOW — First Understand
🔵 FIRST
FIRST(X) is the set of terminals that can appear at the beginning of strings derived from X.
🟣 FOLLOW
FOLLOW(A) is the set of terminals that can appear immediately after the non-terminal A.
⚪ Epsilon
The symbol ε means the empty string. If a symbol can generate ε, we may need to examine the next symbol.
💲 End Marker
The symbol $ represents the end of the input. For the start symbol:
📚 Important Rules
If X is a terminal:
For A → aα:
For the start symbol:
For A → αBβ:
🎓 15 Practice Examples
Grammar
🔎 Step-by-Step Calculation
✅ Final FIRST & FOLLOW
🎬 Animated FIRST → FOLLOW Visualization
Grammar
FIRST
Check ε
FOLLOW
📋 15 Examples — Quick Reference
| No. | Grammar Type | Main Concept |
|---|---|---|
| 1 | Simple Grammar | Basic FIRST |
| 2 | A → a | ε | Epsilon |
| 3 | S → ABC | Multiple Symbols |
| 4 | S → aS | b | Recursion |
| 5 | S → (S)S | ε | Balanced Structure |
| 6 | Expression Grammar | FIRST/FOLLOW |
| 7 | Epsilon Grammar | Propagation |
| 8 | Arithmetic Grammar | LL(1) |
| 9 | Assignment | Terminal After NT |
| 10 | Nested Expression | Nested FOLLOW |
| 11 | Multiple Epsilon | Epsilon Propagation |
| 12 | Boolean Grammar | Logical Operators |
| 13 | List Grammar | Repeated Elements |
| 14 | Statement Grammar | Parser Design |
| 15 | Complex LL(1) | Complete Revision |
⭐ Why FIRST and FOLLOW Are Important?
FIRST and FOLLOW are fundamental for constructing LL(1) predictive parsing tables.
They help the parser select the correct production for a given input symbol.
FOLLOW helps determine when an ε-production should be selected.
They are important concepts in the syntax-analysis phase of compiler design.
No comments:
Post a Comment