Computer Science और IT (कंप्यूटर साइंस)‹›⌂ 0:00 पढ़ाई

Module 8 · 27 मिनट पढ़ाई · मुफ़्त chapter

Syntax-directed translation और intermediate code

संक्षेप में

Syntax-directed definition grammar के साथ attributes और नियम जोड़ती है। Synthesised attributes children से ऊपर आते हैं, inherited वाले parent या बाएँ siblings से। S-attributed नियम LR parsing के साथ और L-attributed नियम LL parsing के साथ ठीक बैठते हैं। Intermediate code अक्सर three-address code होता है, जिसे quadruples या triples में रखा जाता है, और DAG दोहराए subexpressions हटाता है।

आप किस exam की तैयारी कर रहे हैं? हम आपके exam के practice और पिछले साल के सवाल दिखाएँगे।

शून्य से शुरू: दुकान का bill जो जुड़ता चला जाता है

किसी किराना दुकान का bill देखिए। हर line में मात्रा और दर लिखी होती है, और उस line की रकम दोनों का गुणा होती है। नीचे लिखा total, सारी lines की रकमों का जोड़ होता है। यहाँ values ऊपर की ओर चलती हैं, छोटे हिस्सों से पूरे तक।

अब मान लीजिए bill के ऊपर त्योहार की 10 प्रतिशत छूट छपी है। हर line को यही दर इस्तेमाल करनी है, इसलिए यह value ऊपर से हर line तक नीचे की ओर जाती है। यानी bill में दो तरह की जानकारी होती है: एक, जो line अपने हिस्सों से निकालती है, और दूसरी, जो line को ऊपर से मिलती है।

Compiler parse tree पर values ठीक इन्हीं दो तरीकों से लगाता है। Synthesised attribute, total की तरह, children से parent की ओर ऊपर चलता है। Inherited attribute, छूट की तरह, parent से नीचे या किसी sibling से बगल में आता है।

यह क्यों ज़रूरी है? Grammar के साथ ऐसे नियम जोड़कर ही compiler parsing के दौरान types जाँचता है, syntax trees बनाता है और intermediate code तैयार करता है। GATE आपसे किसी input पर ऐसे नियम evaluate करवाता है, और उन्हें S-attributed या L-attributed में बँटवाता है।

Syntax-directed definitions और annotated parse trees

मतलब Production Semantic rule
नतीजा छापना L→E nL \to E\ \mathbf{n} print(E.val)\mathit{print}(E.\mathit{val})
जोड़ना E→E1+TE \to E_1 + T E.val=E1.val+T.valE.\mathit{val} = E_1.\mathit{val} + T.\mathit{val}
ऊपर भेजना E→TE \to T E.val=T.valE.\mathit{val} = T.\mathit{val}
गुणा करना T→T1∗FT \to T_1 * F T.val=T1.val×F.valT.\mathit{val} = T_1.\mathit{val} \times F.\mathit{val}
ऊपर भेजना T→FT \to F T.val=F.valT.\mathit{val} = F.\mathit{val}
Brackets F→(E)F \to (E) F.val=E.valF.\mathit{val} = E.\mathit{val}
Lexer से मिला number F→digitF \to \mathbf{digit} F.val=digit.lexvalF.\mathit{val} = \mathbf{digit}.\mathit{lexval}

Syntax-directed definition (SDD) ऐसी grammar है जिसमें हर symbol के साथ attributes हो सकते हैं, और हर production के साथ semantic rules होते हैं जो उन्हें निकालते हैं। किसी symbol XX का attribute X.valX.\mathit{val} लिखा जाता है। इसका मानक उदाहरण desk calculator है।

E1E_1 में लगा subscript बस एक production में EE की दो copies को अलग करता है। यहाँ हर नियम parent का attribute उसके children से निकालता है, इसलिए हर attribute synthesised है। Digit की value lexer से lexval\mathit{lexval} के रूप में आती है, और terminals के inherited attributes कभी नहीं होते।

हल किया हुआ उदाहरण। Input 3 * 5 + 4 के parse tree में नीचे बाईं ओर F.val=3F.\mathit{val} = 3 और F.val=5F.\mathit{val} = 5 हैं, इसलिए T.val=15T.\mathit{val} = 15 है। दाईं ओर का FF, 4 देता है, और सबसे ऊपर E.val=15+4=19E.\mathit{val} = 15 + 4 = 19 मिलता है। जिस parse tree के nodes पर ऐसी values लिखी हों, उसे annotated parse tree कहते हैं।

ये नियम किस क्रम में चलें? एक dependency graph बनाइए, जिसमें attribute aa से attribute bb तक edge तब हो जब bb का नियम aa इस्तेमाल करे। इस graph का कोई भी topological order सही evaluation order है। अगर graph में cycle हो, तो कोई भी क्रम काम नहीं करता।

यह क्यों ज़रूरी है? "कौन-सी value छपेगी?" वाले सवालों का जवाब annotated parse tree से ही मिलता है। पहले tree बनाकर नीचे से ऊपर values भरने से लगभग हर ग़लती बच जाती है।

S-attributed और L-attributed definitions

जब जानकारी को बगल में या नीचे की ओर जाना हो, तब inherited attributes की ज़रूरत पड़ती है। इसका मशहूर उदाहरण float x, y, z जैसा declaration है। इसमें type पहले पढ़ा जाता है, और उसे बाद में आने वाले हर name तक पहुँचना होता है।

D→T L{L.inh=T.type}D \to T\,L \quad \{L.\mathit{inh} = T.\mathit{type}\}
T→float{T.type=float}T \to \mathbf{float} \quad \{T.\mathit{type} = \mathit{float}\}
L→L1,id{L1.inh=L.inh; addtype(id.entry,L.inh)}L \to L_1 , \mathbf{id} \quad \{L_1.\mathit{inh} = L.\mathit{inh};\ \mathit{addtype}(\mathbf{id}.\mathit{entry}, L.\mathit{inh})\}
L→id{addtype(id.entry,L.inh)}L \to \mathbf{id} \quad \{\mathit{addtype}(\mathbf{id}.\mathit{entry}, L.\mathit{inh})\}

यहाँ L.inhL.\mathit{inh} inherited है: यह बाएँ sibling TT से आता है, और फिर LL nodes की कड़ी में नीचे जाता है। addtype\mathit{addtype} के call से हर identifier की symbol-table entry को उसका type मिल जाता है।

SDD की दो classes को पूरा tree बनाए बिना parsing के दौरान ही evaluate किया जा सकता है। S-attributed SDD में सिर्फ़ synthesised attributes होते हैं। इसे post-order में evaluate किया जा सकता है, और LR parser ठीक इसी क्रम में reductions करता है।

L-attributed SDD में inherited attributes की भी अनुमति है, लेकिन एक शर्त के साथ। A→X1X2…XnA \to X_1 X_2 \dots X_n में XjX_j का inherited attribute सिर्फ़ AA के inherited attributes पर, बाएँ siblings X1,…,Xj−1X_1, \dots, X_{j-1} के attributes पर, और बिना cycle बनाए XjX_j के अपने attributes पर निर्भर हो सकता है। इसलिए जानकारी बाएँ से दाएँ बहती है, और एक ही depth-first, बाएँ से दाएँ वाली यात्रा सब कुछ evaluate कर देती है, जो top-down parsing के साथ ठीक बैठती है।

हल किया हुआ उदाहरण। नियमों B.i=A.iB.i = A.i, C.i=B.sC.i = B.s और A.s=C.sA.s = C.s वाले A→B CA \to B\,C को वर्गीकृत कीजिए। हर inherited attribute parent पर या बाएँ sibling पर निर्भर है, इसलिए यह L-attributed है, लेकिन S-attributed नहीं। अगर इसकी जगह B.i=C.sB.i = C.s होता, तो BB अपने दाएँ sibling से inherit करता, और SDD L-attributed नहीं रहती।

यह क्यों ज़रूरी है? "इनमें से कौन-सी SDD L-attributed है?" GATE का आम सवाल है। हर inherited नियम को जाँचिए, और बस यह देखिए कि वह किसी दाएँ sibling पर या parent के synthesised attribute पर तो निर्भर नहीं है।

Translation schemes: productions के अंदर actions

Syntax-directed translation scheme (SDT) में program के टुकड़े, जिन्हें semantic actions कहते हैं, braces में production bodies के अंदर लिखे जाते हैं। कोई action तब चलता है जब parser उसकी जगह तक पहुँचता है, इसलिए उसकी जगह मायने रखती है। जब सारे actions productions के दाएँ सिरे पर हों, तो SDT को postfix SDT कहते हैं। LR parser हर reduction के समय उसका action चला देता है।

हल किया हुआ उदाहरण (postfix output)। नीचे वाला SDT हर operator को उसके operands के बाद छापता है।

E -> E + T   { print('+') }
E -> E - T   { print('-') }
E -> T
T -> digit   { print(digit.lexval) }

Input 9 - 5 + 2 को left-recursive grammar (9 - 5) + 2 की तरह जोड़ती है। Digits reduce होते ही छप जाते हैं, और हर operator अपने दाएँ operand के बाद छपता है, इसलिए output 9 5 - 2 + आता है, जो postfix रूप है। अगर print actions को bodies के शुरू में रख दें, तो operators पहले छपेंगे। इसीलिए action की जगह बदलने से output बदल जाता है।

हल किया हुआ उदाहरण (GATE जैसा evaluation)। यह SDT देखिए, जिसमें symbols के मतलब अनोखे हैं।

E→E1#T{E.val=E1.val×T.val}E \to E_1 \# T \quad \{E.\mathit{val} = E_1.\mathit{val} \times T.\mathit{val}\}
T→T1 & F{T.val=T1.val+F.val}T \to T_1 \,\&\, F \quad \{T.\mathit{val} = T_1.\mathit{val} + F.\mathit{val}\}
E→T,T→F,F→num{values passed up}E \to T, \quad T \to F, \quad F \to \mathbf{num} \quad \{\text{values passed up}\}

2 # 3 & 5 # 6 & 4 को evaluate कीजिए। Operator & grammar में नीचे है, इसलिए वह ज़्यादा कसकर जुड़ता है, भले ही उसका मतलब जोड़ हो। इसलिए input 2 # (3 & 5) # (6 & 4) की तरह जुड़ता है, और दोनों operators बाईं ओर से जुड़ते हैं।

E.val=2×(3+5)×(6+4)=2×8×10=160E.\mathit{val} = 2 \times (3 + 5) \times (6 + 4) = 2 \times 8 \times 10 = 160

यह क्यों ज़रूरी है? GATE अजीब operators वाले SDTs इसीलिए पसंद करता है, क्योंकि छात्र school वाली precedence लगा देते हैं। Precedence सिर्फ़ grammar के levels से आती है, और associativity recursion की दिशा से।

Three-address code और उसके रूप

क्रम op arg1 arg2 Quadruple का result Triple के arguments
(0) minus c t1 c
(1) गुणा b t1 t2 b, (0)
(2) minus c t3 c
(3) गुणा b t3 t4 b, (2)
(4) जोड़ t2 t4 t5 (1), (3)
(5) assign t5 a a, (4)

ज़्यादातर compilers syntax tree को three-address code में बदलते हैं, जिसमें हर instruction की right side में ज़्यादा से ज़्यादा एक operator होता है। लंबे expression को कदमों में तोड़ा जाता है, और अधूरे नतीजे रखने के लिए compiler temporaries t1,t2,…t_1, t_2, \dots बनाता है। यह नाम सामान्य रूप x=y op zx = y \ \mathit{op}\ z से आया है, जिसमें तीन addresses आते हैं।

Instructions के आम प्रकार कुछ ही हैं। ये हैं: binary assignment x = y op z, unary assignment x = minus y, copy x = y, unconditional jump goto L, conditional jump if x relop y goto L, param x और call p, n वाले procedure calls, indexed assignments x = a[i] और a[i] = x, और address और pointer assignments x = &y, x = *p और *p = x।

हल किया हुआ उदाहरण (एक loop)। 4-byte integers के साथ C का loop s = 0; for (i = 0; i < n; i++) s = s + a[i]; नीचे वाला code बन जाता है।

1: s = 0
2: i = 0
3: if i >= n goto 9
4: t1 = 4 * i
5: t2 = a[t1]
6: s = s + t2
7: i = i + 1
8: goto 3
9: return s

Three-address code को तीन तरह से रखा जा सकता है। a = b * -c + b * -c लीजिए, जिसका code t1 = minus c, t2 = b * t1, t3 = minus c, t4 = b * t3, t5 = t2 + t4 और a = t5 है; तीनों रूप ऊपर की table में हैं।

Quadruples में चार fields होते हैं, op, arg1, arg2 और result, और हर temporary का नाम साफ़ लिखा होता है। Triples में result वाला field नहीं होता, और किसी value को उस triple की position से बताया जाता है जो उसे निकालता है, इसलिए (1) का मतलब है "instruction 1 का नतीजा"। Indirect triples में triples के pointers की एक अलग list होती है, इसलिए optimiser triples को छुए बिना list का क्रम बदल सकता है।

यह क्यों ज़रूरी है? Optimiser लगातार instructions की जगह बदलता है। साधारण triples में किसी instruction को हिलाने से positions बदल जाती हैं, और उसके सारे references टूट जाते हैं। इसीलिए optimising compilers में quadruples और indirect triples पसंद किए जाते हैं।

Syntax trees, DAGs और SSA form

Syntax tree एक छोटा किया हुआ parse tree है। इसके अंदरूनी nodes operators होते हैं और leaves operands, और E→T→FE \to T \to F जैसी कड़ियाँ हटा दी जाती हैं। DAG, यानी directed acyclic graph, एक कदम आगे जाता है। यह हर अलग subexpression को एक ही node देता है, जिसे उसे इस्तेमाल करने वाली हर जगह साझा करती है।

DAG बनाते समय नया node बनाने से पहले उसे खोजिए। अगर उसी operator और उन्हीं children वाला node पहले से मौजूद है, तो उसी को फिर इस्तेमाल कीजिए; नहीं तो नया node बनाइए। आमतौर पर hashing से होने वाली यही खोज common subexpressions ढूँढती है।

हल किया हुआ उदाहरण। a+a∗(b−c)+(b−c)∗da + a * (b - c) + (b - c) * d के nodes गिनिए। Syntax tree में 7 leaves (aa, aa, bb, cc, bb, cc, dd) और 6 operator nodes हैं, यानी 13 nodes। DAG में leaves aa, bb, cc और dd एक-एक बार आती हैं, और b−cb - c एक बार बनकर साझा होता है, इसलिए 4 leaves और 5 operator nodes, यानी 9 nodes हैं।

a = b * -c + b * -c के DAG में minus c और b * t1, दोनों साझा होते हैं। इसके code में सिर्फ़ चार instructions लगती हैं: t1 = minus c, t2 = b * t1, t3 = t2 + t2 और a = t3। पिछले section का छह lines वाला code इसलिए छोटा हो गया, क्योंकि DAG ने दोहराव पकड़ लिया।

Static single-assignment (SSA) form ऐसा intermediate code है जिसमें हर variable को ठीक एक बार assign किया जाता है। हर नया assignment एक नया version बनाता है, इसलिए x = a + b; x = x * 2; y = x + 1 बदलकर x1 = a + b; x2 = x1 * 2; y1 = x2 + 1 बन जाता है। अब हर use ठीक एक definition का नाम लेता है, जिससे कई optimisations आसान हो जाते हैं।

जब control के दो रास्ते मिलते हैं, तो हर रास्ते पर किसी variable का अलग version हो सकता है। SSA इन्हें φ-function से जोड़ता है। अगर एक branch x3=1x_3 = 1 करती है और दूसरी x4=2x_4 = 2, तो मिलने की जगह पर x5=ϕ(x3,x4)x_5 = \phi(x_3, x_4) आता है। φ-function उस रास्ते का version चुनता है जिससे program सच में आया।

यह क्यों ज़रूरी है? GATE किसी DAG के nodes की गिनती और temporaries की कम से कम संख्या पूछता है। DAG ही local common-subexpression elimination का औज़ार है, जिसका नाम syllabus में सीधे लिखा है।

Backpatching, संक्षेप में

जब compiler if (x < 5 or y > 2) S को translate करता है, तो उसे SS की शुरुआत पर और उसके आगे jumps लिखने पड़ते हैं, जबकि उसे अभी पता नहीं कि ये जगहें कहाँ हैं। एक हल दो passes हैं। Backpatching यही काम एक pass में करती है: वह jump targets ख़ाली छोड़ देती है और बाद में भरती है।

हर boolean expression BB के साथ ख़ाली targets वाली instructions की दो lists रहती हैं। B.truelistB.\mathit{truelist} में वे jumps हैं जो BB के true होने पर लेने हैं, और B.falselistB.\mathit{falselist} में false वाले। इन्हें तीन functions संभालते हैं: makelist(i)\mathit{makelist}(i) instruction ii वाली नई list बनाता है, merge(p1,p2)\mathit{merge}(p_1, p_2) दो lists जोड़ता है, और backpatch(p,i)\mathit{backpatch}(p, i) list pp के हर jump में target ii लिख देता है।

B→B1 or M B2:backpatch(B1.falselist,M.instr), B.truelist=merge(B1.truelist,B2.truelist), B.falselist=B2.falselistB \to B_1 \ \mathbf{or}\ M\, B_2: \quad \mathit{backpatch}(B_1.\mathit{falselist}, M.\mathit{instr}),\ B.\mathit{truelist} = \mathit{merge}(B_1.\mathit{truelist}, B_2.\mathit{truelist}),\ B.\mathit{falselist} = B_2.\mathit{falselist}

Marker M→εM \to \varepsilon, M.instrM.\mathit{instr} यानी अगली instruction का number याद रखता है, और वहीं से B2B_2 शुरू होता है। अगर B1B_1 false है, तो control को आगे B2B_2 जाँचना है, इसलिए B1B_1 के false jumps को M.instrM.\mathit{instr} से भरा जाता है। and में भूमिकाएँ बदल जाती हैं: B1B_1 के true jumps को B2B_2 की शुरुआत से भरा जाता है, और false lists जोड़ दी जाती हैं।

हल किया हुआ उदाहरण। Instruction 100 से शुरू करने पर condition से नीचे वाला code बनता है। Truelist {100,102}\{100, 102\} है, जिसे 104 से भरा जाता है जहाँ SS शुरू होता है। Falselist {103}\{103\} है, जिसे SS के बाद वाली पहली instruction से भरा जाता है।

100: if x < 5 goto _      (true: patched to 104)
101: goto 102             (false of x < 5: patched to start of y > 2)
102: if y > 2 goto _      (true: patched to 104)
103: goto _               (false: patched to after S)

यह क्यों ज़रूरी है? Backpatching से ही one-pass compilers conditions और loops के लिए सही jump code बनाते हैं। Exam के सवाल आमतौर पर पूछते हैं कि किसी list में क्या है, या कौन-सा target किसी ख़ाली जगह को भरेगा।

Descriptive lens: लिखित paper यह कैसे पूछते हैं

Scientist पदों के लिखित paper और university की परीक्षाएँ इस topic को चार तरह से पूछती हैं:

  1. Synthesised और inherited attributes, और S-attributed और L-attributed definitions को परिभाषित करना और उनमें अंतर बताना, हर एक के उदाहरण के साथ।
  2. किसी input के लिए annotated parse tree और dependency graph बनाना, और evaluation order बताना।
  3. किसी statement या loop को three-address code में बदलना, और उसके quadruples, triples और indirect triples दिखाना।
  4. किसी expression या basic block का DAG बनाना, और उससे common subexpressions हटाना।

अभ्यास सवाल (हमारे अपने, पिछले वर्षों के सवाल नहीं)।

  1. Desk calculator के लिए एक SDD लिखिए और (4 + 2) * 3 का annotated parse tree बनाइए। क्या आपकी SDD, S-attributed है? (10 अंक)
  2. x = (a + b) * (a + b) - c को three-address code में बदलिए, और उसे quadruples, triples और indirect triples के रूप में दिखाइए। (15 अंक)
  3. S-attributed और L-attributed definitions में अंतर बताइए। Declaration int p, q, r से दिखाइए कि inherited attributes की ज़रूरत क्यों है। (10 अंक)

सवाल 3 का answer plan।

  • शुरुआत में synthesised और inherited attributes को परिभाषित कीजिए, और बताइए कि parse tree में हर एक किस दिशा में बहता है।
  • S-attributed SDD को ऐसी SDD के रूप में परिभाषित कीजिए जिसमें सिर्फ़ synthesised attributes हों, और जिसे LR parsing के दौरान post-order में नीचे से ऊपर evaluate किया जाए।
  • L-attributed SDD को उसकी शर्त से परिभाषित कीजिए, कि inherited attributes सिर्फ़ parent के inherited attributes और बाएँ siblings पर निर्भर हों।
  • Declaration के चारों नियम लिखिए, जिनमें L.inh=T.typeL.\mathit{inh} = T.\mathit{type}, TT से LL तक और फिर list में नीचे जाता है।
  • int p, q, r का annotated tree बनाइए, और दिखाइए कि addtype\mathit{addtype} हर symbol-table entry में type integer रखता है।
  • निष्कर्ष लिखिए कि type सिर्फ़ बाएँ sibling को पता है, इसलिए सिर्फ़ synthesised scheme अतिरिक्त काम के बिना उसे names तक नहीं पहुँचा सकती।

Quick revision

  • SDD grammar के साथ attributes और semantic rules जोड़ती है, जबकि SDT production bodies के अंदर actions रखता है।
  • Synthesised attributes children से आते हैं, inherited वाले parent या siblings से, और terminals के सिर्फ़ synthesised attributes होते हैं।
  • S-attributed SDDs में सिर्फ़ synthesised attributes होते हैं और ये LR parsing के साथ ठीक बैठती हैं, जबकि L-attributed SDDs में parent और बाएँ siblings से inheritance की भी अनुमति है।
  • हर S-attributed SDD, L-attributed है, और dependency graph में cycle हो तो evaluation असंभव है।
  • SDT में precedence grammar के levels से आती है, और associativity recursion की दिशा से।
  • Three-address code की हर instruction की right side में ज़्यादा से ज़्यादा एक operator होता है।
  • Quadruples में चार fields होते हैं, triples में तीन होते हैं और वे position से बताते हैं, और indirect triples pointers की list जोड़ते हैं।
  • DAG हर अलग subexpression को एक node देता है, इसलिए a+a∗(b−c)+(b−c)∗da + a * (b - c) + (b - c) * d के लिए 13 की जगह 9 nodes चाहिए।
  • SSA हर variable को एक assignment देता है और जहाँ रास्ते मिलते हैं वहाँ φ-functions लगाता है।
  • Backpatching jump targets को truelists और falselists में ख़ाली छोड़ती है और बाद में भरती है।

ख़ुद को परखें

इस chapter पर exam जैसे सवाल। जवाब चुनिए, फिर उसकी व्याख्या देखिए। 15 में से 0 हल किए

  1. Syntax-directed translation scheme में semantic actions कहाँ होते हैं?

  2. Node का जो attribute उसके children के attributes से निकलता है, वह क्या कहलाता है?

  3. SDD में terminals के कैसे attributes हो सकते हैं?

  4. A→B CA \to B\,C के लिए कौन-सा नियम SDD को L-attributed नहीं रहने देता?

  5. कौन-सा कथन सही है?

  6. SDD के attributes को evaluate करने का सही क्रम किससे मिलता है?

  7. दाएँ सिरे पर print actions के साथ E→E+T∣E−T∣TE \to E + T \mid E - T \mid T, T→digitT \to \mathbf{digit} का SDT 9 - 5 + 2 के लिए क्या छापेगा?

  8. अगर E→E1#TE \to E_1 \# T का मतलब गुणा और T→T1 & FT \to T_1 \,\&\, F का मतलब जोड़ हो, तो 2 # 3 & 5 # 6 & 4 की value क्या है?

  9. कौन-सी instruction सही three-address code नहीं है?

  10. कौन-सा रूप optimiser को references बदले बिना instructions का क्रम बदलने देता है?

  11. Quadruple में कितने fields होते हैं?

  12. a+a∗(b−c)+(b−c)∗da + a * (b - c) + (b - c) * d के DAG में कितने nodes हैं?

  13. SSA form में ϕ\phi-function कहाँ रखा जाता है?

  14. B→B1 or M B2B \to B_1 \ \mathbf{or}\ M\, B_2 की backpatching में कौन-सी list M.instrM.\mathit{instr} से भरी जाती है?

  15. GATE 2026 CS syllabus में Compiler Design के अंतर्गत कौन-सा topic लिखा है?

पिछले साल के सवाल (PYQ)

UPSC CSE के पिछले साल के सवाल यहाँ तभी दिखेंगे, जब हर सवाल को official question paper से शब्दशः मिला लिया जाएगा।

AI के साथ सीखें

ऐसा tutor जो बताने की जगह पूछता है, ऐसा साथी जो दूसरा पक्ष रखता है, और यह chapter आपके अपने ज़िले के उदाहरणों से।

Tutor को बताइए कहाँ अटके हैं। वह सवालों से रास्ता दिखाएगा और कुछ कोशिशों के बाद जवाब देगा।

🙋 Doubt पूछें या feedback दें

कहीं अटके, या कोई गलती दिखी? ExamHike team को लिखिए। आम तौर पर एक दिन में जवाब आता है, और जवाब आपके My progress page पर दिखेगा।

Doubt पूछने या feedback देने के लिए login करें →

अक्सर पूछे जाने वाले सवाल

S-attributed और L-attributed SDDs में क्या अंतर है?

S-attributed SDDs में सिर्फ़ synthesised attributes होते हैं। L-attributed SDDs में ऐसे inherited attributes भी चलते हैं जो parent के inherited attributes और बाएँ siblings पर निर्भर हों।

Three-address code क्या है?

यह ऐसा intermediate code है जिसकी हर instruction की right side में ज़्यादा से ज़्यादा एक operator होता है, जैसे t1 = b * c, और इसमें compiler के बनाए temporaries होते हैं।

Quadruples, triples से कैसे अलग हैं?

Quadruples में साफ़ result समेत चार fields होते हैं। Triples में तीन fields होते हैं और वे results को position से बताते हैं, जिससे क्रम बदलना मुश्किल होता है।

Expressions के लिए DAG क्यों इस्तेमाल होता है?

DAG हर अलग subexpression को एक साझा node देता है, इसलिए दोहराया गया काम पकड़ में आता है और एक ही बार होता है।

इस module के और chapter: Compiler design (कंपाइलर डिज़ाइन)

Official स्रोत

इस chapter के तथ्य इन official स्रोतों से मिलाकर जाँचे गए हैं।

  1. GATE 2026 Computer Science and Information Technology (CS) syllabus, IIT Guwahati
  2. NPTEL Compiler Design (IIT Kharagpur, 106105190): syntax-directed translation and intermediate code generation