- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Three Address Code GenerationBackpatching-I.ppt
Three Address Code GenerationBackpatching-I Prepared By: Siddharth Tiwary 04CS3010 For the examples of the previous lectures for implementing syntax-directed definitions, the easiest way is to use two passes. First syntax tree is constructed and is then traversed in depth-first order to compute the translations given in the definition. The main problem in generating three address codes in a single pass for Boolean expressions and flow of control statements is that we may not know the labels that control must go to at the time jump statements are generated. This problem is solved by generating a series of branch statements with the targets of the jumps temporarily left unspecified. Each such statement will be put on a list of goto statements whose labels will be filled in when the proper label can be determined. This subsequent filling of addresses for the determined labels is called BACKPATCHING. For implementing Backpatching ,we generate quadruples into a quadruple array and Labels are indices to this array. To manipulate list if labels ,we use three functions: makelist(i),merge(p1,p2) and backpatch(p,i). makelist(i) : creates a new list containing only i, an index into the array of quadruples and returns pointer to the list it has made. merge(i,j) – concatenates the lists pointed to by i and j ,and returns a pointer to the concatenated list. backpatch(p,i) – inserts i as the target label for each of the statements on the list pointed to by p. Let’s now try to construct the translation scheme for Boolean expression. Lets the grammar be: E → E1 or ME2 E → E1 and ME2 E → not E1 E → (E1) E → id1 relop id2 E → false E → true M → ε What we have done is inserting a marker non-terminal M into the grammar to cause a semantic action to pick up, at appropriate times the index of the next quadruple to be generated. This is done by the semantic action: { M.Quad = nextquad } for the rule M → ε Two synthesized attribu
您可能关注的文档
- Part One.ppt
- Passive voice.ppt
- pc-公司财务.ppt
- PEP6 Unit4 What are you doingPart A Let's learn.ppt
- Physics 207, Sept. 12, The inclined plane and unit conversion.ppt
- PL编译器实习框架.ppt
- Postmodern City & Space of Flows.ppt
- PowerPoint2000交互式技术.ppt
- Presented by Melissa DarkCERIAS, Purdue University.ppt
- Priority Themes in the World Bank's Gender Work.ppt
- TI青年教师培训.ppt
- TreesCLRS chapter 12.ppt
- Trends in Pre-K and K-12 Education.ppt
- U3T2 What Sweet Music!Section B.ppt
- UML发展历史.ppt
- Unit 12 Advanced Hydrogeology.ppt
- UNIT 12 Travel.ppt
- Unit 12 What's the best radio stationSection B.ppt
- Unit 12-13Infectious DiseaseEpidemiology.ppt
- Unit 2 As soon as it's 12 o'clock….ppt
文档评论(0)