Presentation is loading. Please wait.

Presentation is loading. Please wait.

Backpatching דוגמא : switch. דוגמא switch : הדקדוק.

Similar presentations


Presentation on theme: "Backpatching דוגמא : switch. דוגמא switch : הדקדוק."— 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 →case num : 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 CL 1 { CL.quad_list = CL 1.quad_list; CL.quad_list.push(C.quad); CL.value_list = CL 1. value_list; CL.value_list.push(C.value); CL.nextlist = merge( C.nextlist, CL 1.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 __”); }


Download ppt "Backpatching דוגמא : switch. דוגמא switch : הדקדוק."

Similar presentations


Ads by Google