- 20
- 0
- 约9.37千字
- 约 46页
- 2018-11-05 发布于广西
- 举报
* Tree Languages Statement Stm ? Stm; Stm (CompoundStm) | id := Exp (AssignStm) | print(ExpList) (PrintStm) Exp Exp ? id (IdExp) | num (NumExp) | Exp Binop Exp (OpExp) | (Stm, Exp) (EseqExp) * Example a := 5 + 3 ; b := (print(a, a-1), 10*a); print (b) Output 8, 7 80 * CompoundStm AssignStm CompoundStm a OpExp NumExp NumExp plus AssignStm b EseqExp PrintStm LastExpList IdExp b printStm OpExp NumExp NumExp Times 10 a PairExpList a LastExpList OpExp IdExp NumExp Minus a 1 5 3 * Front end scanner parser source IR token errors * Front end Responsibilities: recognize legal procedure report errors produce IR preliminary storage map shape the code for the back end Much of front end construction can be automated * Scanner Maps characters into tokens the basic unit of syntax a := a - 1 becomes id, a; :=, ; id, a; -, ; num, 1 A lexeme is a value for a token : character string, integer typical tokens: numb, id, +, -, …… Eliminates white space (tabs, blanks, comments) A key issue is speed use specialized recognizer (as opposed to lex) * Parser Parser recognize context-free syntax guide context-sensitive analysis construct IR produce meaningful error messages attempt error correction Parser generators mechanize much of the work * Back End Responsibilities translate IR into target machine code choose instructions for each IR operation decide what to keep in registers at each point ensure conformance with system interfaces Automation has been less successful here * Three pass compilers Analysis Synthesis source HIR target Optimizer LIR errors Analyzes and changes IR The goal is to reduce runtime Optimizer must preserve values * Optimizer * * Data Structures typedef struct A_stm_ *A_stm ; typedef struct A_exp_ *A_exp ; typedef struct A_expList *A_expList ; typedef enum { A_plus, A_minus, A_times, A_div } A_binop ; * Data Structures struct A_stm_ { enum { A_CompoundStm, A_assignStm, A_prin
您可能关注的文档
- 比的基本性质课件(适合人教版)(精品·公开课件).ppt
- 比较级&虚拟(精品·公开课件).ppt
- 比较少见的英文咨询报告(精品·公开课件).ppt
- 比较优势贸易理论(精品·公开课件).ppt
- 比较语言学 绪论(精品·公开课件).ppt
- 比较政治学绪论(精品·公开课件).ppt
- 比例尺公式(精品·公开课件).ppt
- 比赛场次(精品·公开课件).ppt
- 比赛1(精品·公开课件).ppt
- 比赛场次1(精品·公开课件).ppt
- 伟明环保-市场前景及投资研究报告-境内业务稳健运行,印尼市场贡献边际增量.pdf
- 桂东县法院系统招聘考试真题2025.pdf
- 贵州省黔南布依族2026年中考三模物理试题及答案.pdf
- 贵州省黔南州2026年中考语文二模试卷附答案.pdf
- 贵州省铜仁市2026年中考语文二模试卷附答案.pdf
- 2026上半年安徽事业单位联考合肥市庐江县招聘36人备考题库及一套完整答案详解.docx
- 贵州省毕节市2026年中考语文一模试卷附答案.pdf
- 贵州省贵阳市南明区2026年中考语文一模试卷附答案.pdf
- 2026上半年安徽事业单位联考合肥市庐江县招聘36人备考题库及一套参考答案详解.docx
- 贵州省贵阳市白云区2026年中考二模物理试题附答案.pdf
最近下载
- 2025年演出经纪人话剧_舞台剧项目收益分配模式专题试卷及解析.pdf VIP
- 2025年演出经纪人演出保险方案的招标与采购流程专题试卷及解析.pdf VIP
- 2025年人力资源管理师残疾人职工就业保障与权益保护专题试卷及解析.pdf VIP
- 2025年信息系统安全专家数据安全生命周期管理专题试卷及解析.pdf VIP
- 2025年碳排放管理师碳边境调节机制零碳工厂建设专题试卷及解析.pdf VIP
- 医疗护理安全警示教育案例.pptx VIP
- 优质护理服务PPT课件.pptx VIP
- 2025年房地产经纪人二手房交易行为规范专题试卷及解析.pdf VIP
- 2025年互联网营销师敏捷项目管理在营销中的应用专题试卷及解析.docx VIP
- 2025年项目管理专业成本补偿合同最新政策解读专题试卷及解析.pdf VIP
原创力文档

文档评论(0)