Short trick to find the given grammar is (LL1) or not in Compiler Design In Hindi.
Short trick to find the given grammar is (LL1) or not in Compiler Design In Hindi.
Contents [hide]
- 1 LL(1) Grammar पहचानने की Short Trick | Compiler Design (in Hindi)
- 2 Short Trick to Check LL(1) Grammar
- 3 Quick LL(1) Checking Shortcut
- 4 Final Summary (One-Liner Trick)
- 5 Short trick to find the given grammar is (LL1) or not in Compiler Design In Hindi.
- 6 ACADEMIC REGULATIONS COURSE STRUCTURE AND …
- 7 An Autonomous Institution
LL(1) Grammar पहचानने की Short Trick | Compiler Design (in Hindi)
LL(1) Grammar एक Top-Down Parsing तकनीक है, जिसमें Left-to-Right scanning और Leftmost derivation का उपयोग किया जाता है, और इसमें 1 Lookahead symbol होता है।
Short Trick to Check LL(1) Grammar
किसी भी दिए गए Grammar को LL(1) Grammar है या नहीं, यह चेक करने के लिए दो मुख्य Conditions होती हैं:
Step 1: First & First Condition (No Common Terminals in First Sets)
हर Non-Terminal के लिए FIRST सेट आपस में Disjoint (अलग-अलग) होने चाहिए।
अगर किसी एक ही Non-Terminal की दो Productions में Common Terminal आता है, तो Grammar LL(1) नहीं होगी।
Example (NOT LL(1)):
FIRST(S) = {a, a} (Common Terminal ‘a’ है) → Not LL(1)
Step 2: First & Follow Condition (No Conflict in Parsing Table)
अगर A → α | β और FIRST(α) ∩ FIRST(β) ≠ ∅ (Common Elements) हैं, तो Grammar LL(1) नहीं होगी।
अगर ε (epsilon) FIRST में है, तो FIRST(α) ∩ FOLLOW(A) = ∅ होना चाहिए।
Example (LL(1)):
FIRST(A) = {c, ε} और FOLLOW(A) = {b}
FIRST(A) और FOLLOW(A) में कोई Common Element नहीं है → LL(1) Grammar है।
Quick LL(1) Checking Shortcut
Step 1: FIRST सेट में Common Terminals नहीं होने चाहिए।
Step 2: अगर ε (epsilon) है, तो FIRST और FOLLOW का Intersection Empty होना चाहिए।
Step 3: अगर कोई भी Rule इन Conditions को तोड़ता है → Grammar LL(1) नहीं है।
Final Summary (One-Liner Trick)
अगर किसी भी Non-Terminal की FIRST Sets Overlap नहीं करती और ε होने पर FOLLOW से Confusion नहीं होता, तो Grammar LL(1) होगी!
अगर आपको कोई और Example चाहिए तो पूछ सकते हैं!