Compiler Construction Principles & Implementation Techniques

Download Report

Transcript Compiler Construction Principles & Implementation Techniques

Software College of Northeast Normal University
编译程序的面向对象设计与实现
Dr. Zheng Xiaojuan
Professor
Software College of Northeast Normal University
Mar. 2010
Compiler Construction Principles & Implementation Techniques
-1-
本课程与其它专业及实践课程的关系
Software College of Northeast Normal University
1. C++程序设计语言(前导课程: C程序设计语言)
2. 项目拉动教学(基础项目)
C0解释程序的面向对象设计与实现(所需理论与实践
: C++语言、Visical C++6.0、面向对象程序设计)
3. 编译程序构造原理与实现技术(前导课程: 离散数学
、数据结构、 C及C++程序设计语言、操作系统)
4. 项目拉动教学(实训项目)
编译器的面向对象设计与实现(所需理论与实践:编
译原理、C++语言、Visical C++6.0、数据结构、面
向对象程序设计、软件工程)
Compiler Construction Principles & Implementation Techniques
-2-
Software College of Northeast Normal University
• Optional Textbooks
[1] Aho, Alfred V., Ravi Sethi, and Jeffrey Ullman. Compilers:
Principles, Techniques and Tools. Reading, MA: AddisonWesley, 1986. ISBN: 0201100886.
[2] Appel, Andrew W. Modern Compiler Implementation in Java.
Cambridge, UK: Cambridge University Press, 1997. ISBN:
0521583888.
[3] Kenneth C. Louden. Compiler Construction: Principles and
Practice. PWS Publishing Company, 1997. IBSN 0-534-3972-4.
[4] 金成植 《编译程序构造原理与实现技术》高等教育出版社.
[5] 刘磊 《编译程序的设计与实现》高等教育出版社.
Compiler Construction Principles & Implementation Techniques
-3-
开发编译器的目的
Software College of Northeast Normal University
1.
2.
3.
4.
5.
加深对程序设计语言的理解。因为设计一个编译程序,需要准确认识
程序语言的语法和语义,了解目标机及目标代码的结构,这些知识对
于学习新的程序设计语言是非常有帮助的。
编译程序本身是一个十分庞大而复杂的系统软件,涉及到许多复杂的
数据结构和实现算法,若能系统全面的掌握编译技术,必将大大提高
程序设计能力,特别是开发大型软件的能力。
编译技术可以应用于许多实际的软件开发工作中,如软件开发平台、
软件自动生成、模式匹配等许多方面。
可以培养学生的抽象思维能力,掌握形式化描述技术,这种思想和方
法可能对今后从事的软件开发工作产生深远的影响。
编译程序是一种元级程序,即它处理的对象就是程序,因此学习编译
原理和实现技术,对于我们掌握元级程序设计方法十分有帮助。(编译
程序、解释程序、程序转换、程序分析、程序调试)
Compiler Construction Principles & Implementation Techniques
-4-
Software College of Northeast Normal University
源语言
• 面向过程:
SNL[5]
C-[1][3]
• 面向对象:
MiniJava[2]
Compiler Construction Principles & Implementation Techniques
-5-
Software College of Northeast Normal University
程序设计方法
• 面向过程:
[3][5]
• 面向对象:
[1][2]
Compiler Construction Principles & Implementation Techniques
-6-
Software College of Northeast Normal University
教学方式与学习、开发方法
教学方式:
 小组设计开发,阶段全体授课,小组汇报
学习、开发方法(建议):
 熟练编译技术
 精通源语言;(SNL,C-,MiniJava)
 精通开发语言;(C,C++,Java,C#)
 熟悉目标语言;(汇编语言,虚拟机)
 熟悉开发环境;(VC++6.0-MFC, VC++2008-.net,eclips)
 强调全局思维;
 参考源程序;
Compiler Construction Principles & Implementation Techniques
-7-
Software College of Northeast Normal University
考核方法
每4人分成一开发小组,集体验收,单独考察。
1. 优: 面向对象方法开发
词法分析
语法分析
符号表管理与语义分析
目标代码生成
能够正确编译执行源程序
2. 良:面向对象方法开发
词法分析
语法分析
符号表管理与语义分析
生成源程序的语法树和符号表.
3. 中:面向过程方法开发
词法分析、语法分析、符号表管理与语义分析
4. 及:词法分析、语法分析
5. Compiler
不: Construction Principles & Implementation Techniques
-8-
Software College of Northeast Normal University
1.
2.
3.
4.
5.
6.
7.
编译器开发时间安排
源语言学习(1周)
词法分析(3周)
语法分析(4周)
符号表管理与语义分析 (4周)
目标代码生成(3周)
界面(2周)
验收(2周)
Compiler Construction Principles & Implementation Techniques
-9-
Software College of Northeast Normal University
开发编译器的性能要求
可移植性;
可扩展性;
可维护性;
编译可靠性;
编译速度;
目标代码的运行速度;
空间节省;
Compiler Construction Principles & Implementation Techniques
-10-
Software College of Northeast Normal University
小组讨论要求
(1)认真,不缺席
(2)组长主持,有人记录(记录要求:时间、地点
、人物、发言)
(3)地点不限
(4)全体组员达成共识:完成项目开发文档。
Compiler Construction Principles & Implementation Techniques
-11-
Software College of Northeast Normal University
阶段一:源语言学习
Compiler Construction Principles & Implementation Techniques
-12-
Software College of Northeast Normal University
第一次小组讨论题目:
1. 源语言的理解:词法、语法、语义
2. 复习词法分析的token数据结构表示、DFA的构
造和实现。
Compiler Construction Principles & Implementation Techniques
-13-