设计并实现计算机器类c,本科毕业论文题目一个类C解析器的设计与实现.doc

普通本科毕业论文题目:一个类C解析器的设计与实现

摘要编译程序是现代计算机系统的基本组成部分,从功能上看,一个编译程序是一个语言翻译程序,它把一种语言称作源语言书写的程序翻译成另一种语言称作目标语言书写的等价的程序.

本系统的目标是应用在大学阶段学习的理论知识,进行一个简单的类C解析器的设计与实现并尽可能地做一定的改进.本文介绍了语法分析器、中间语言、语义翻译器三部分的实现过程,其中语法分析器中的仿YACC程序并没有直接生成分析程序,而是生成LALR分析表,这样做的好处是任何语言都可以用这张分析表,为了提高仿YACC程序的速度,采用了造核算法和SPONSOR算法.在语义翻译器中解决了在C语言编译器中全局变量名不能与自定义函数名重名和指针变量指向多维数组不能正常访问的问题.

【关键词】 C语言表达式;LALR分析表;解释器

The Design and implementation of similar C language

Ou yang tian

Abstract:

Compiling program is one basic part of the modern computer system. From the functional perspective, a compiling program is a language translation program which can translate a program written by a language called source language into another equivalent program written by a language called objective language.

The objective of this system is the design and implementation of a simple expression compiler of the C language and does some improvements of functions as far as possible by using theory knowledge learned during the college. This paper mainly introduces the implemental process of grammar analyzer, intermediate language and semantic translator, and the YACC program of the grammar analyzer does not generate the analytical program directly but LALR analytical table. In this way, every language can use this table. In order to enhance the speed of the YACC, we use the accounting method and algorithm SPONSOR. In the part of semantic translator, we have resolved the problem that the name of global variables and user defining variables can't be the same and pointer variables which point to multi-dimensional array do not access normally in the compiler of the C language.

Keywords:

C language expression; LALR analysis table; Interpreter

目录1引言 1

1.1 开发模型 1

1.2 实现方案 2

2 语法分析器 3

2.1 LALR表生成工具 4

2.1.1 C语言文法 5

2.1.2 仿YACC程序 8

2.2 语法分析 13

3 中间语言 16

4 语义翻译器 17

4.1 数据结构 18

4.1.1 符号表 18

4.1.2 系统栈 18

4.2 表达式翻译 18

4.2.1 隐式类型转换 19

4.2.2 强制类型转换 20

4.3 控制结构、函数与指针的实现 21

4.3.1 循环语句与判断语句翻译 21

4.3.2 自定义函数翻译 21

4.3.3 系统函数的封装 22

4.3.4 指针实现 22

5 总结 23

参考文献 24

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值