1 / 5

Realizácia zotavenia (1)

Realizácia zotavenia (1). Každú funkciu reprezentujúcu pravidlo EBNF je potrebné doplniť o parameter keys reprezentujúci množinu kľúčov (typu KeySet ) int Expr ( KeySet keys ) { ... } Volanie getsymbol () nahradiť : if (symbol == a ) { g etsymbol (); } else {

brosh
Download Presentation

Realizácia zotavenia (1)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Realizácia zotavenia (1) • Každú funkciu reprezentujúcu pravidlo EBNF je potrebné doplniť o parameter keys reprezentujúci množinu kľúčov (typu KeySet) intExpr(KeySetkeys){ ... } • Volanie getsymbol() nahradiť: if (symbol == a) { getsymbol(); } else { error(e, keys); }

  2. Realizácia zotavenia (2) • Pri volaní procedúr zodpovedajúcich neterminálnym symbolom doplniť argument s aktuálnou hodnotou množiny kľúčov. leftOp = Mul(allKeys); • Do každého bodu rozhodnutia (if+else, switch, while) umiestniť volanie check v tvare: check(e, keys);

  3. Zotavenie pri postupnosti neterminálov • A → S1 S2 S3 ... Si ... Sn A(KeySet keys) { S1 (H(S2) ⋃ H(S3)⋃ ... ⋃ H(Sn) ⋃ keys); S2 (H(S3) ⋃... ⋃ H(Sn) ⋃ keys); ... Si (H(Si+1)⋃ ... ⋃ H(Sn) ⋃ keys); ... Sn (keys); }

  4. Zotavenie pri vetvení • A → (S1 | S2 | ... | Sn) A(KeySet keys) { KeySetallkeys = H(S1) ⋃ ... ⋃ H(Sn) ⋃ keys; check(e,allkeys); switch (symbol) { caseH(S1): S1(keys); break; ... caseH(Sn): Sn(keys); break; default: error(e, keys); } }

  5. Zotavenie pri cykle • A → {S1 S2 ... Sn} A(keys) { loopkeys = H(S1) ⋃ ... ⋃ H(Sn); allkeys = loopkeys⋃ keys; check(e, allkeys); while (symbol ∈ loopkeys) S1(allkeys); S2(allkeys); ... Sn(allkeys); check(e, allkeys); } }

More Related