1 / 11

Backpatching

Backpatching. דוגמא: switch. דוגמא switch :. הדקדוק. שלבי פיתרון. שלב I – תרשים פריסת הקוד. שלב II – סכימת תירגום. תכונות סמנטיות שנצטרך S – nextlist E – place C – value, quad, nextlist CL – nextlist , quad_list (stack) value_list (stack). שלב II – סכימת תירגום.

Download Presentation

Backpatching

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. Backpatching דוגמא: switch

  2. דוגמא switch :

  3. הדקדוק

  4. שלבי פיתרון

  5. שלב I – תרשים פריסת הקוד

  6. שלב II – סכימת תירגום • תכונות סמנטיות שנצטרך S –nextlist E – place C – value, quad, nextlist CL – nextlist, quad_list (stack) value_list (stack)

  7. שלב II – סכימת תירגום • מרקרים שימושים N →ε { N.nextlist = makelist(nextquad); emit('goto ___'); } M →ε { M.quad = nextquad(); }

  8. שלב II – סכימת תירגום • הכללים סמנטיים: C →casenum: M S ;break; { C.quad = M.quad; C.value = num.value; C.nextlist = S.nextlist; }

  9. שלב II – הכללים סמנטיים C L → C { CL.quad_list = newstack(); CL.quad_list.push(C.quad); CL.value_list = newstack(); CL.value_list.push(C.value); CL.nextlist = C.nextlist; }

  10. שלב II – הכללים סמנטיים C L → C CL1 { CL.quad_list = CL1.quad_list; CL.quad_list.push(C.quad); CL.value_list = CL1. value_list; CL.value_list.push(C.value); CL.nextlist = merge( C.nextlist, CL1.nextlist); }

  11. שלב II – הכללים סמנטיים S → switch(E N){CL} { backpatch(N.nextlist, nextquad() ); while (!CL.value_list.empty()) { value = CL.value_list.pop(); quad= CL. quad_list.pop(); emit('if' || E.place || '=' ||value || 'goto‘ ||quad); } S.nextlist = merge(CL.nextlist, makelist(nextquad()); emit(“goto __”); }

More Related