前言
此项目记录了一个小型编译器——CMM语言编译器(解释器)的开发过程,项目所需要的前导理论课程为编译原理。
In this programming project, you will design and implement an interpreter of CMM language, using the principles you learned in Compiler Principles course. The interpreter will read CMM source codes and make the lexical analysis, syntax analysis and semantic analysis on the codes. If it encounters errors, reports them. If no errors are encountered, your interpreter will give the execution result directly.
在此项目中,将实现一个CMM语言(详见下一目)的编译器。该编译器能够实现词法分析、语法分析、语义分析以及中间代码生成(主要为四元式的构造)等基本过程,也包括图形用户界面的设计,最终将以一个简易IDE(集成开发环境)的形式呈现。
CMM语言
CMM(C Minus Minus/C- -)语言为C语言的一个子集,其基础定义如下:
- 语言结构:顺序结构(赋值语句、输入、输出)、选择语句(if-else)、循环结构(whileÿ