编译原理-1-述.ppt

  1. 1、本文档共56页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
编译原理-1-述

术语 语义分析(semantic analysis) The parsed program is further analyzed to determine whether it conforms to the source language’s contextual constraints:scope rules, type rules e.g. To relate each applied occurrence of an identifier in the source program to the corresponding declaration. 中间代码生成 源程序的内部(中间)表示 三元式、四元式 ( * id3 t1 t2 ) t2 = id3 * t1 id1:= id2 + id3 * 60 (1) (inttoreal, 60 - t1 ) (2) (* , id3 t1 t2 ) (3) (+ , id2 t2 t3 ) (4) (:= , t3 - id1 ) 中间代码生成(intermediate code generation) This is where the intermediate representation of the source program is created.We want this representation to be easy to generate,and easy to translate into the target program.The representation can have a variety of forms, but a common one is called three-address code or 4- tuple code. 代码优化 id1:= id2 + id3 * 60 (1) (inttoreal 60 - t1 ) (2) ( * id3 t1 t2 ) (3) ( + id2 t2 t3 ) (4) ( := t3 - id1 ) 变换 ? (1) ( * id3 60.0 t1 ) ( 2)( + id2 t1 id1 ) 代码优化 t1 = b* c t1 = b* c t2 = t1+ 0 t2 = t1 + t1 t3 = b* c a = t2 t4 = t2 + t3 a = t4 代码优化(code optimization) Intermediate code optimization The optimizer accepts input in the intermediate representation and output a version still in the intermediate representation .In this phase,the compiler attempts to produce the smallest,fastest and most efficient running result by applying various techniques. Object code optimization 目标代码生成 (* , id3 60.0 t1 ) (+ , id2 t1 id1 ) movf id3,R2 mulf #60.0,R2 movf id2,R1 addf R2,R1 movf R1,id1 符号表管理 记录源程序中使用的名字 收集每个名字的各种属性信息 类型、作用域、分配存储信息 Const1 常量 值:35 Var1 变量 类型:实 层次:2 符号表(symbol table) Symbol table is a data structure which is employed to associate identifiers with their attributes . An identifier’s attribute consists of information relevant to contextual analysis,and is obtained from the identifier’s declaration. 出错处理 检查错误、报告出错信息、排错、恢复编译工作 * * *

文档评论(0)

quechui388620 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档