文件名称:lab2
介绍说明--下载内容均来自于网络,请自行研究使用
任务是在词法分析和语法分析程序的基础上编写一个程序,对C 源代码进行语义分析和类型检查,并打印分析结果。与实验一不同的是,实验二不再借助已有的工具,所有的任务都必须手写代码来完成。另外,虽然语义分析在整个编译器的实现中并不是难度最大的任务,但却是最细致、琐碎的任务。因此需要用心地设计诸如符号表、变量类型等数据结构的实现细节,从而正确、高效地实现语义分析的各种功能。
需要注意的是,由于在后面的实验中还会用到本次实验已经写好的代码,因此保持一个良好的代码风格、系统地设计代码结构和各模块之间的接口对于整个实验来讲相当重要。 -Task was to prepare the basis of lexical analysis and syntax analysis program on a program source code for C semantic analysis and type checking, and print the results. The first experiment is different, no longer by means of experiment two existing tools, all tasks must be done hand-written code. In addition, although the semantic analysis is not the most difficult task in the whole compiler implementation, but it is the most detailed, trivial task. Therefore it needs careful design implementation details such as the symbol table, variable types of data structures, which correctly and efficiently implement various functions of semantic analysis.
It should be noted that, due later in the experiment will be used in this experiment has been written code, so keeping the interface between a good coding style, system design and code structure for each module in terms of the whole experiment quite important.
需要注意的是,由于在后面的实验中还会用到本次实验已经写好的代码,因此保持一个良好的代码风格、系统地设计代码结构和各模块之间的接口对于整个实验来讲相当重要。 -Task was to prepare the basis of lexical analysis and syntax analysis program on a program source code for C semantic analysis and type checking, and print the results. The first experiment is different, no longer by means of experiment two existing tools, all tasks must be done hand-written code. In addition, although the semantic analysis is not the most difficult task in the whole compiler implementation, but it is the most detailed, trivial task. Therefore it needs careful design implementation details such as the symbol table, variable types of data structures, which correctly and efficiently implement various functions of semantic analysis.
It should be noted that, due later in the experiment will be used in this experiment has been written code, so keeping the interface between a good coding style, system design and code structure for each module in terms of the whole experiment quite important.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
code\data_structure.c
....\data_structure.h
....\lexical.l
....\main.c
....\parser
....\syntax.y
....\treenode.c
....\treenode.h
code