收藏 分享(赏)

(5.4.2)--4.4.2SimulatetheParsingofInherit.pdf

上传人:职教中国 文档编号:13787737 上传时间:2022-10-22 格式:PDF 页数:18 大小:1.23MB
下载 相关 举报
(5.4.2)--4.4.2SimulatetheParsingofInherit.pdf_第1页
第1页 / 共18页
(5.4.2)--4.4.2SimulatetheParsingofInherit.pdf_第2页
第2页 / 共18页
(5.4.2)--4.4.2SimulatetheParsingofInherit.pdf_第3页
第3页 / 共18页
亲,该文档总共18页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

1、Compilers TechniquesSyntax-DirectedTranslatione.g. Language for typesetting mathematical formula(EQN)S B.ps := 10 B S.ht := B.ht B B1.ps := B.ps B1 B2.ps := B.ps B2 B.ht := max(B1.ht, B2.ht ) B B1.ps :=B.ps B1sub B2.ps := shrink(B.ps) B2 B.ht := disp (B1.ht, B2.ht ) B text B.ht := text.h B.ps Simula

2、te the Computation of Inherited AttributesWhen computing the font and height of text, it is impossible to determine the position of the inherited attribute values on which it depends.For example, the top of the stack element may be.text = BB text = B BB sub text = B sub BSimulate the Computation of

3、Inherited AttributesSimulate the Computation of Inherited AttributesProduction Semantic rulesS LB B.ps := L.s; S.ht := B.htL L.s := 10 B B1 MB2 B1.ps := B.ps; M.i := B.ps;B2.ps := M.s; B.ht := max(B1.ht, B2.ht )M M.s := M.iB B1 sub NB2 B1.ps := B.ps; N.i := B.ps;B2.ps := N.s; B.ht := disp(B1.ht, B2.

4、ht )N N.s := shrink(N.i) B text B.ht := text.h B.psSimulate the Computation of Inherited AttributesSM BL BBtextE B sub N BtextE text1s=10 psps s pshth=E.hh=E.h spsii psh=1.hhththththtSimulate the Computation of Inherited AttributesSimulate the Computation of Inherited AttributesProduction Semantic r

5、ulesS LB B.ps := L.s; S.ht := B.htL L.s := 10 B B1 MB2 B1.ps := B.ps; M.i := B.ps;B2.ps := M.s; B.ht := max(B1.ht, B2.ht )M M.s := M.iB B1 sub NB2 B1.ps := B.ps; N.i := B.ps;B2.ps := N.s; B.ht := disp(B1.ht, B2.ht )N N.s := shrink(N.i) B text B.ht := text.h B.psPut B.ps into the stack to useSimply f

6、or predictable attribute positionsFunction of calculationSimulate the Computation of Inherited AttributesProduction Semantic rulesS LB B.ps := L.s; S.ht := B.htL L.s := 10 B B1 MB2 B1.ps := B.ps; M.i := B.ps;B2.ps := M.s; B.ht := max(B1.ht, B2.ht )M M.s := M.iB B1 sub NB2 B1.ps := B.ps; N.i := B.ps;

7、B2.ps := N.s; B.ht := disp(B1.ht, B2.ht )N N.s := shrink(N.i) B text B.ht := text.h B.psRewrite to stack codeSimulate the Computation of Inherited AttributesProduction Semantic rulesS LB B.ps := L.s; S.ht := B.htL L.s := 10 B B1 MB2 B1.ps := B.ps; M.i := B.ps;B2.ps := M.s; B.ht := max(B1.ht, B2.ht )

8、M M.s := M.iB B1 sub NB2 B1.ps := B.ps; N.i := B.ps;B2.ps := N.s; B.ht := disp(B1.ht, B2.ht )N N.s := shrink(N.i) B text B.ht := text.h B.psSimulate the Computation of Inherited AttributesProduction Semantic rulesS LB B.ps := L.s; S.ht := B.htL L.s := 10 B B1 MB2 B1.ps := B.ps; M.i := B.ps;B2.ps :=

9、M.s; B.ht := max(B1.ht, B2.ht )M M.s := M.iB B1 sub NB2 B1.ps := B.ps; N.i := B.ps;B2.ps := N.s; B.ht := disp(B1.ht, B2.ht )N N.s := shrink(N.i) B text B.ht := text.h B.psSimulate the Computation of Inherited AttributesProduction Code segmentsS LB stacktop1.val := stacktop.valL L.s := 10 B B1 MB2 B1

10、.ps := B.ps; M.i := B.ps;B2.ps := M.s; B.ht := max(B1.ht, B2.ht )M M.s := M.iB B1 sub NB2 B1.ps := B.ps; N.i := B.ps;B2.ps := N.s; B.ht := disp(B1.ht, B2.ht )N N.s := shrink(N.i) B text B.ht := text.h B.psSimulate the Computation of Inherited AttributesProduction Code segmentsS LB stacktop1.val := s

11、tacktop.valL stacktop+1.val := 10B B1 MB2 B1.ps := B.ps; M.i := B.ps;B2.ps := M.s; B.ht := max(B1.ht, B2.ht )M M.s := M.iB B1 sub NB2 B1.ps := B.ps; N.i := B.ps;B2.ps := N.s; B.ht := disp(B1.ht, B2.ht )N N.s := shrink(N.i) B text B.ht := text.h B.psSimulate the Computation of Inherited AttributesPro

12、duction Code segmentsS LB stacktop1.val := stacktop.valL stacktop+1.val := 10B B1 MB2 stacktop2.val :=max(stacktop2.val, stacktop.val)M M.s := M.iB B1 sub NB2 B1.ps := B.ps; N.i := B.ps;B2.ps := N.s; B.ht := disp(B1.ht, B2.ht )N N.s := shrink(N.i) B text B.ht := text.h B.psSimulate the Computation o

13、f Inherited AttributesProduction Code segmentsS LB stacktop1.val := stacktop.valL stacktop+1.val := 10B B1 MB2 stacktop2.val :=max(stacktop2.val, stacktop.val)M stacktop+1.val := stacktop1.valB B1 sub NB2 B1.ps := B.ps; N.i := B.ps;B2.ps := N.s; B.ht := disp(B1.ht, B2.ht )N N.s := shrink(N.i) B text

14、 B.ht := text.h B.psSimulate the Computation of Inherited AttributesProduction Code segmentsS LB stacktop1.val := stacktop.valL stacktop+1.val := 10B B1 MB2 stacktop2.val :=max(stacktop2.val, stacktop.val)M stacktop+1.val := stacktop1.valB B1 sub NB2 stacktop3.val:= disp (stacktop3.val, stacktop.val

15、 )N N.s := shrink(N.i) B text B.ht := text.h B.psSimulate the Computation of Inherited AttributesProduction Code segmentsS LB stacktop1.val := stacktop.valL stacktop+1.val := 10B B1 MB2 stacktop2.val :=max(stacktop2.val, stacktop.val)M stacktop+1.val := stacktop1.valB B1 sub NB2 stacktop3.val:= disp

16、 (stacktop3.val, stacktop.val )N stacktop+1.val := shrink(stacktop2.val)B text B.ht := text.h B.psSimulate the Computation of Inherited AttributesProduction Code segmentsS LB stacktop1.val := stacktop.valL stacktop+1.val := 10B B1 MB2 stacktop2.val :=max(stacktop2.val, stacktop.val)M stacktop+1.val := stacktop1.valB B1 sub NB2 stacktop3.val:= disp (stacktop3.val, stacktop.val )N stacktop+1.val := shrink(stacktop2.val)B text stacktop.val := stacktop.val stacktop1.valCompilers TechniquesSyntax-DirectedTranslation

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 大学课件

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报