编译原理》实验教学大纲

课程代码

045100293

课程名称

编译原理

英文名称

Principles ofCompiler

课程类别

选修课

课程性质

选修

学时

总学时:48,实验学时:16,其他学时:16

学分

2.5

开课学期

第四学期

开课单位

计算机科学与工程学院,计算机教学实验中心

适用专业

计算机科学与技术全英创新班、计算机科学与技术全英联合班

授课语言

英语

先修课程

高级语言程序设计、数据结构、计算机组成与体系结构

毕业要求(专业培养能力)


本课程对学生达到如下毕业要求有如下贡献:

1.(工程知识)培养学生熟练掌握英语,掌握扎实的计算机科学与技术专业基本原理、方法和手段等方面的基础知识用于解决复杂工程问题,并通过计算机系统分析、建模和计算等方面的先进方法,为将所学基础知识应用到计算机科学与技术研发和工程实践做好准备。

2.(问题分析)培养学生能够创造性地利用计算机科学基本原理解决计算机领域遇到的问题。

3.(设计/开发解决方案)能够设计针对计算机工程复杂问题的解决方案,设计满足特定需求的计算机软硬件系统,并能够在设计环节中体现创新意识,考虑社会、健康、安全、法律、文化以及环境等因素。

4.(研究)培养学生具备计算机系统相关知识并对计算机工程复杂问题进行研究,具有计算机系统研发基本能力、具备问题分析和建模的能力,具有系统级的认知能力和实践能力,掌握自底向上和自顶向下的问题分析方法。

5.(使用现代工具)能够针对计算机工程复杂问题,开发、选择与使用恰当的技术、资源、现代工程工具和信息技术工具。


课程培养学生的能力(教学目标)


完成课程实验后,学生将具备以下能力:

1.掌握编译器各个阶段工作的实现,能为小型高级程序语言构造编译器,完成从该高级语言程序到目标程序的转换。[3,4,5]

2.掌握计算机科学中抽象问题和表示问题的方法,掌握高级程序设计语言的词法、语法和语义的形式化表示方法。[3,4]

3.能根据理论部分学习的编译各阶段的实现方法,设计针对具体程序设计语言的实现方案。[3,4]

  1. 掌握使用高级程序设计语言工具,编码实现编译器各个阶段的工作。[3,5]


课程简介


编译原理课程内容较抽象,理解难度大,实验是其中的一个重要环节。实验通过对一个较完整的编译器的开发,让学生对编译的各组成部分的实现技术有更好的理解,同时掌握编译的各部分如何整合,从而形成一个完整的编译系统。通过实验,学生可深入理解所学的理论知识,熟悉编译中的一些重要算法的应用,基本掌握编译器构造的方法,提高理论联系实际的能力。另外,在实验过程中,学生将数据结构、高级程序设计语言等相关知识内容进行综合运用,提高了学生的计算机综合应用能力。


主要仪器设备与软件

PC机:硬件:PIII500以上;操作系统:Windows8Windows10

虚拟机VirtualBox6或以上;

实验报告

考核方式


实验课考核方式包括上机检查实验完成情况,及提交实验源代码和实验报告。

考核的评分标准:

40%:是否完成了实验规定的全部内容,运行结果是否正确,系统运行是否稳定;

30%:提交的实验源代码编写是否规范;

30%:实验报告中对实验方案设计是否合理,实验步骤和方法是否正确,描述是否充分。

实验教学环节占课程总成绩的20%,实验教学环节中预习、考勤、实验纪律占实验环节总成绩的20%,提交的实验报告和实验源代码的完成情况占实验环节总成绩的40%,上机检查占实验环节总成绩的40%


教材、实验指导书及教学参考书目

教材:无

实验指导书:由所引进的MOOC课程提供

AlexAiken, Compilers, Stanford Online Lagunita,https://lagunita.stanford.edu/courses/Engineering/Compilers/Fall2014/about


制定人及发布时间

刘欣欣,20190408


《编译原理》实验教学内容与学时分配

实验项目编号

实验项目名称

实验学时

实验内容提要

实验类型

实验要求

每组人数

主要仪器设备与软件


搭建实验虚拟环境,熟悉COOL程序设计语言

4


  1. 搭建实验环境,实验在虚拟机VirtualBox中完成

  2. 获取虚拟机镜像文件Compilers.vbox.在该镜像中安装了Linux操作系统以及实验所需的全部工具软件。

  3. 熟悉实验要编译的源语言Cool程序设计语言


设计性

必做

1

PC机:硬件:PIII500以上;操作系统:WindowsXPWindows8Windows10

编程语言:CC++


构造COOL语言的词法分析器


4


使用词法分析器的自动生成器flex,构造COOL语言的词法分析器

  1. 熟悉Flex的规则和使用方法

  2. Flex的规则定义COOL语言中各类单词

  3. 构造词法分析器的动作,包括:返回所识别的单词,记录单词的值,当出现词法错误时报告词法错误


设计性

必做

1

PC机:硬件:PIII500以上;操作系统:Windows8Windows10

VirtualBox 6或以上


构造COOL语言的语法分析器


4


用词法分析器的自动生成器,bison,构造COOL语言的词法分析器

  1. 熟悉YACC规则的定义和bison的使用方法

  2. 定义非终结符的类型声明和过程声明

  3. COOL语法定义转换成YACC规则


设计性

必做

1

PC机:硬件:PIII500以上;操作系统:Windows8Windows10

VirtualBox 6或以上


构造COOL语言语法分析器的输出,抽象语法树

4

构造COOL语言语法分析器的输出,抽象语法树

  1. YACC规则中添加生成抽象语法树的动作

  2. 添加进行语法错误处理的动作

设计性

必做

1

PC机:硬件:PIII500以上;操作系统:Windows8Windows10

VirtualBox 6或以上

Principlesof Compiler” Experiment Syllabus

Course Code

045100293

Course Title

Principles ofCompiler

Course Category

Elective Courses

Course Nature

Elective Course

Class Hours

Class Hours: 48, ExperimentHours:16, Other:16

Credits

2.5

Semester

The Fourth Semester

Institute

School ofComputer Science & Engineering, Laboratory of ComputerTeaching

Program Oriented

Computer Scienceand Technology Full English Creative Class, Computer Science andTechnology Full English Union Class

Teaching Language

English

Prerequisites

AdvancedLanguage Programmer, Data Structure, Computer Organization andArchitecture

Student Outcomes (SpecialTraining Ability)


1.EngineeringKnowledge: An ability to apply knowledge of English, solidknowledge of professional basic principles, methods and means ofcomputer science and technology for solving complex engineeringproblems, to well prepare the required knowledge applied to thecomputer science and technology research & development andengineering practice through computer systems analysis, modelingand calculation and any other aspects of the advanced approach.

2.ProblemAnalysis: An ability to creatively use the basic principles ofcomputer science to solve the problems encountered in the computerfield.

3.Design/ Development Solutions: An ability to design solutions forcomputer engineering complex problems, to design computer hardwareand software systems that meet with specific requirements, and toembody innovation awareness in the design process and take intoaccount social, health, safety, cultural and environmentalfactors.

4.Research:An ability to develop computer system-related knowledge andresearch computer engineering complex issues, to develop the basiccapacity of computer systems research & development,systematic cognitive and practice, master the Bottom-up andtop-down problem analysis methods.

5.ApplyingModern Tools: An ability to develop, select and use appropriatetechnologies, resources, modern engineering tools and informationtechnology tools for complex computer engineering issues.


Teaching Objectives


1.Through the construction of a compiler, students will reallyappreciate the theory, apply the important algorithms for eachstep in the compilation process and understand how all the partsof a compiler fit together. [3,4,5]

2.Understanding the basic techniques of compiler construction,especially the construction of scanner, parser, semantic analyzerand intermediate code generator. [3,4]

3.Familiar with the source language to be compiled, including itslexical, syntax and semantic regulation. Design the structure ofcompiler basing on the source language and the properties thecompiler wants to have. Determine the operations done by each passof compiling. [3,4]

4. Develop thecode for each phase of the compiler using the important algorithmsdesigned for scanning, parsing, semantic analyzing and codegenerating. [3,5]

Course Description


Experimentof compiler construction is an important part of the coursePrinciples of Compiler. It plays a key role in helping students tounderstand the underlying theory and training students’abilities to programming an actual compiler. Students are asked todo a compiler project for designing and implementing a compilerfor a small language. Having traced through and implemented thevarious phases of compilation, you will gain a clear understandingof how a compiler works. You will learn standard techniques thatcan be applied to a variety of compilation problems. Exposure toprogramming language implementation will strengthen yourdevelopment and debugging skills and generally aid yourunderstanding of language and programming issues.


Instruments and Equipments

PC:Hardware: PIII500 or above; Operating SystemWindows8Windows10

VirtualBox 6 orabove

Experiment Report

Yes

Assessment


Sourcecodes and reports must be submitted for the experiment. Gradingwill be based on both the quality of report and the organizationand correctness of the source codes.

Theoverall grade of the experiment will be assigned using thefollowing weights

40%:experiment is completed and submitted before the due date. Programwritten works correctly;

30%:quality of the experiment report

30%:organization and correctness of the submitted code


Teaching Materials andReference Books


NoTextbook for the experiments

Instructionfor the experiments is provide by MOOC:

AlexAiken, Compilers, Stanford Online Lagunita,https://lagunita.stanford.edu/courses/Engineering/Compilers/Fall2014/about


Prepared by Whomand When

Xinxin Liu, 8thApril, 2019

Principlesof Compiler” ExperimentalTeaching Arrangements

No.

ExperimentItem

Class Hours

ContentSummary

Category

Requirements

Number ofStudentsEach Group

Instruments,Equipments and Software

1

Getting started with thevirtual machine and COOL programming language.

4


  1. Setup the experiment environment. The experiment will be donedinside the virtual machine(VM) VirtualBox

  2. Getthe VM image file: Compilers.vbox. It’s a pre-configured Linuxsystem with all the needed tools installed.

  3. Familiarwith the Cool Programming Language


Design

Compulsory

1

PC:Hardware: PIII500 or above; Operating SystemWindows8Windows10

VirtualBox 6 or above

2

Writea lexical analyzer of COOL programming language


4


Usinga lexical analyzer generator, flex, to build the COOL lexicalanalyzer

  1. Familiarwith Flex rules and the use of Flex

  2. WriteFlex rules that match on the appropriate regular expressionsdefining valid tokens in Cool

  3. Performthe appropriate actions:

Returninga token

Recordingthe value of a lexeme

Reportingan error when an error is encountered


Design

Compulsory

1

PC:Hardware: PIII500 or above; Operating SystemWindows8Windows10

VirtualBox 6 or above

3

Writea parser for COOL programming language


4


Usinga parser generator, bison, to build the COOL parser

  1. Familiarwith YACC rules and the use of Bison

  2. Addtype declarations for non-terminals, add precedence declarations.

  3. Turnthe cool syntax to YACC rules


Design

Compulsory

1

PC:Hardware: PIII500 or above; Operating SystemWindows8Windows10

VirtualBox 6 or above

4

Generate the output of theparser, that is an abstract syntax tree(AST)

4

Buildthe output of the parser, that is an abstract syntax tree(AST)

  1. Addthe actions for AST generation to rules

  2. Error handling

Design

Compulsory

1

PC:Hardware: PIII500 or above; Operating SystemWindows8Windows10

VirtualBox 6 or above