登录

  • 登录
  • 忘记密码?点击找回

注册

  • 获取手机验证码 60
  • 注册

找回密码

  • 获取手机验证码60
  • 找回
毕业论文网 > 毕业论文 > 计算机类 > 软件工程 > 正文

编译过程可视化软件的设计与实现毕业论文

 2021-03-21 10:03  

摘 要

高级程序设计语言转化为可由目标机直接执行的低级语言共有两种常见的转化方式:编译与解释。然而由于解释的效率不高,因此在实际的应用中通常使用编译的方法。为了是学生更加容易的理解编译的原理及方法,很多高校都开设了《编译原理》课程。

在编译原理的教学过程中,知识点较多,算法较为难以理解,概念较为抽象都是比较难以解决的问题。针对编译原理整体较为抽象的概念,传统的教学方法很难全面地展示计算机领域知识的动态性与抽象性。为了应对这种情况,本文设计了简单编译器的可视化演示软件,实现了一个简单的类Pascal语言编译系统。可对于词法分析、语法分析、语义分析及生成中间代码等过程进行可视化的展示。该软件可以作为教学辅助工具,帮助学生全面高效地理解编译原理的课程相关内容。

本系统主要包含以下几个模块的内容:词法分析、语法分析、语义分析和中间代码生成。同时可对于这几个模块进行可视化的演示。

本系统选择了Microsoft Visual Studio为开发工具,编程语言选择C与C ,实现了类Pascal语言的词法分析、语法分析、语义处理、中间代码生成的可视化过程展示。同时本系统采用了黑盒测试方法对系统进行了界面和功能测试。

本论文采用软件工程的思想对于整个系统进行了相关的需求分析、详细设计、系统实现、系统测试等多个过程,并且对相关背景及开发工具进行了介绍。

关键词:编译器;编译过程可视化;词法分析;语法分析;语义分析

Abstract

The high-level programming language is translated into low-level languages that can be directly executed by the target machine. There are two common ways of transformation: compiling and interpreting. However, due to the low efficiency of interpretation, the compilation method is usually used in practical applications. In order to make it easier for students to understand the principles and methods of compiling, many universities have set up the course of compiling principles.

In the teaching process of Fundamentals of Compiling, the knowledge points are more, the algorithm is more difficult to understand and the concept is more abstract.All of these things above are big problems. In order to deal with this situation, this paper designed a simple compiler visual demonstration software, to achieve a simple class Pascal language compiler system which can show lexical analysis, parsing, semantic analysis and generation of intermediate code. The software can be used as a teaching aids to help students comprehensively understand the curriculum-related content of the compilation principles.

The system mainly contains the following modules: lexical analysis, parsing, semantic analysis and intermediate code generation. At the same time, these modules can be visually demonstrated.

This system chose Microsoft Visual Studio as development tools, programming languages C and C , realizes the analysis and visualization of class Pascal language lexical syntax analysis and semantic processing, intermediate code generation display. At the same time, this system uses the black box testing method to interface and function test.

This paper uses the idea of software engineering to the whole system of the relevant requirements analysis, detailed design, system implementation, system testing and other processes, and the background and development tools are introduced.

Key Words:Compiler;Parsing;Scanning ;Visualization

目 录

第1章 绪论 1

1.1 课题背景 1

1.2 研究现状及发展趋势 1

1.3 课题目的及意义 1

1.4 相关技术介绍 1

1.4.1 C语言简介 1

1.4.2 MFC简介 2

1.4.3 Microsoft Visual Studio简介 2

第2章 需求分析和总体设计 4

2.1 需求分析 4

2.1.1 界面需求 4

2.1.2 功能需求 4

2.1.3 可靠性需求 5

2.2 总体设计 5

2.2.1 编译程序的组成 5

2.2.2 各模块设计 5

2.2.2.1 词法分析: 5

2.2.2.2 语法分析: 6

2.2.2.3 语义分析: 6

2.2.2.4 中间代码生成: 6

2.2.3 源语言的词法及语法 7

第3章 功能具体实现 8

3.1 词法分析模块 8

3.2 语法分析模块 10

3.2.1 LL(1)语法分析 10

3.2.2 递归下降语法分析 13

3.3 语义分析模块 14

3.3.1 概述 14

3.3.2 主要任务 15

3.3.3 具体实现 15

3.4 中间代码生成模块 17

3.4.1 概述 17

3.4.2 关键函数 17

第4章 系统测试及运行结果 19

4.1 单元测试 19

4.1.1 模块间调用测试 19

4.1.2 主要类调用测试 19

4.1.3接口函数测试 20

4.1.4 界面测试 20

4.2 功能测试 21

4.2.1 等价类 21

4.2.2 测试用例 22

4.3 运行结果 22

4.3.1 词法分析运行结果 24

4.3.2 语法分析运行结果 26

4.3.3 语义分析运行结果 27

4.3.4 中间代码生成运行结果 28

第5章 总结和展望 30

参考文献 31

致谢 33

第1章 绪论

1.1 课题背景

当今我们所使用的程序设计语言,之所以能从原本的计算机专用的及其语言发展到如今通用的多种如Java、C、C 、python等高级语言,就是在编译技术的发展下形成的。

编译原理是计算机及相关专业为了让学生更加深入了解计算机原理所安排的一门关键的必修课程。这门课在理论、技术、方法等各个方面都对学生进行了规范且专业的训练,对于学生软件开发方面的素质和能力都有非常大的帮助。因此大多数高校的计算机相关专业都开设了《编译原理》课程,并将其设为专业课程之一,由于编译过程较为复杂,且在其不同阶段皆有多种实现方法,因此,学生在该课程的学习较为困难。

1.2 研究现状及发展趋势

近年来,编译原理主要的发展趋势有三个:

1.通过使用更加复杂的算法来使得对应语言的编译更加高效,同时也可以通过更多的算法来实现对应语言的更多高级功能。

2.随着可视化交互开发环境(IDE)的发展,越来越多的编译器并不以单独的形式存在,而是作为IDE的一个组成部分。而IDE的发展也使得编译器被更加广泛的使用与了解。

3.随着计算机走进了千家万户,各大高校对于计算机的课程安排也越来越多,越来越重要。编译原理现在以及成为计算机及相关专业在大学课程安排中必不可少的一门课程。

1.3 课题目的及意义

针对编译原理整体较为抽象的概念,传统的教学方法很难全面地展示计算机领域知识的动态性与抽象性。当今,计算机辅助教学(Computer Aided Instruction ,简称CAI)已经进入各大高校。因此,利用CAI开展可视化教学,可以充分展示编译原理知识。编译过程可视化软件的设计与实现就是为了达到让学生可视化学习编译原理的目的。

1.4 相关技术介绍

1.4.1 C语言简介

C语言是一种高级编程语言,在过去的软件发展史中,具有着不可磨灭的强大地位。即使是现在,由于其效率高,且容量小的特点,也是较为流行的一种编程语言。C语言由于其编译器实现较为容易,因此在各大系统如windows、Linux、Unix中都可以实现编译。作为一个非常经典的语言,后续许多高级编程语言如C 、Objective-C、C#等语言中都可以看到C语言的影子。

您需要先支付 80元 才能查看全部内容!立即支付

企业微信

Copyright © 2010-2022 毕业论文网 站点地图