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.



play-rounded-fill play-rounded-outline play-sharp-fill play-sharp-outline
pause-sharp-outline pause-sharp-fill pause-rounded-outline pause-rounded-fill
00:00

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)):

SaA | aB
Ax
By

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)):

SaA | b
Ac | ε

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 चाहिए तो पूछ सकते हैं!

Short trick to find the given grammar is (LL1) or not in Compiler Design In Hindi.

ACADEMIC REGULATIONS COURSE STRUCTURE AND …

An Autonomous Institution



Leave a Reply

Your email address will not be published. Required fields are marked *

error: