Compiler Presentation (Group 1)
Compiler Presentation (Group 1)
code
Presented By
Md. Shahin Miah Md. Shahariar Alom
ID: 221-15-5646 ID: 221-15-4829
Focus Areas:
✓ Eliminate left recursion
✓ Apply left factoring for LL(1).
Goals:
✓ Identify and resolve left recursion
✓ Apply transformations to remove ambiguity
✓ Ensure deterministic parsing decisions
Background Study
Approach:
❖ Recursion Task: Grammar: S → A a | b, A → S c |d
❖ Identify and eliminate direct/indirect left recursion
Approach:
❖ Factoring Task: Grammar: S → A(B)C | A0C | SD, A → id | num, etc.
❖ Factor out common prefixes for LL(1) compatibility
Task 1 - Eliminating Left
Recursion
Consider indirect left recursion, where the parser loops indefinitely. This task resolves it
• A→Sc|d a|b
Resulting Grammar
• S → d a S' | b S’
• S' → c a S' | ε
Task 1 - Findings &
Analysis
Results:
Grammar is non-left-recursive, suitable for top-down parsing
LL(1)-compatible, avoids infinite loops
Analysis:
Transformation resolves parsing ambiguity
Ensures deterministic parsing decisions
Challenges:
Task 1 - Findings &
Analysis
Challenges:
• Manual substitution can be error-prone for complex grammars
• Parsing table verification recommended for practical use
Expert Opinion:
• Hypothetical consultation with Dr. Jane Doe, Compiler Tools Engineer
• Left recursion elimination and factoring are foundational for tools like ANTLR,
JavaCC
Insights:
• Modern compilers automate transformations, but manual understanding aids
debugging
• Manual techniques align with industry for small grammars; tools preferred for
scalability
Implications:
• Mastery of these techniques prepares for real-world compiler development
• Impacts parser performance and efficiency
Task 2 - Left Factoring
Summary: Future Directions:
• Eliminated left recursion: S → • Explore automated grammar
d a S' | b S', S' → c a S' | ε transformation tools
• Applied left factoring: S → A S', • Study bottom-up parsing (e.g.,
S' → (B)C | 0C | D. LR parsers)
• Produced LL(1)-compatible Learning Experience:
grammars • Deepened understanding of
Relevance: grammar transformations.
• Critical for efficient, • Balanced theoretical and
deterministic parsers. practical parsing needs.
• Used in tools like Yacc, Bison,
and language parsing
Thanks
Teacher Resources
Press 0-9 for a timer
B C D
B is for blur C is for confetti B is for blur
O Q X
O is for Bubbles Q is for Quiet X is for close