资源简介
实现词法,语法,语义翻译器,程序中包含转移函数,生成四元式

代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#define S 0;
#define R 1;
#define ACC 2;
#define AND 0
#define BEGIN 1
#define DO 2
#define ELSE 3
#define END 4
#define FOR 5
#define IF 6
#define NOT 7
#define OR 8
#define PROG 9
#define READ 10
#define THEN 11
#define TO 12
#define WHILE 13
#define WRITE 14
#define VAR 15
#define ID 16
#define INTEGER 17
#define REAL 18
#define PLUS 19
#define MINUS 20
#define MULTI 21
#define RDIV 22
#define EQ 23
#define LT 24
#define GT 25
#define LE 26
#define GE 27
#define NE 28
#define LR_BRAC 29
#define RR_BRAC 30
#define COMMA 31
#define ASSIGN 32
#define SEMIC 33
#define COLON 34
#define TRUE 35
#define FALSE 36
#define NUMBER 37
#define LS_BRAC 38
#define RS_BRAC 39
#define ARRAY 40
#define OF 41
#define PROC 42
#define CALL 43
#define RETURN 44
#define VOID 45
#define ENDING 46
#define P 47
#define D 48
#define List 49
#define SS 50 //from S
#define Sp 51 //from S‘
#define SB 52
#define Lp 53
#define T 54
#define L 55
#define Left 56
#define PList 57
#define E 58
#define ET 59
#define EEp 60
#define EF 61
#define ETp 62
#define B 63
#define BE 64
#define BT 65
#define BEp 66
#define C 67
#define EList 68
#define M_d 69
#define M_bool 70
#define M_con 71
#define N_con 72
#define M_for 73
#define wordnum 47;
using namespace std;
typedef int type;///属性
typedef int state;///状态
typedef int pos;///中间变量位置
typedef struct{
string type;///“real“/“integer“
int int_val;
double real_val;
}number_val;
typedef struct{
type typ;///词的属性
int pos;///变量位置
void * ptr;///指向中间变量属性
number_val * num_ptr;///指向数字属性值
}SIGN;
///---------LexicalAnalyzer------------
/*typedef struct{
char name[30];
char type[10];
int value;
}id;*/
//id variable[200];
int int_cnt=0;
int int_buf[1000];
int real_cnt=0;
double real_buf[1000];
int cnt=0;///统计句子长度
SIGN buff[200];///读入句子缓冲区
int id_cnt=0;///记录变量数量
string id_name[1000];///记录变量名
///---------SyntaxAnalyzer-------------
typedef struct{
string pro;///产生式
int left;///产生式左边
int num;///产生式右边符号数
}production;
state state_stak[1000];///存放状态的栈
void * ptr_stak[1000];///存放对应符号栈的中间变量具体是哪个的栈
SIGN sign_stak[1000];///存放符号的栈
int top=0;
//SIGN buff[50];///缓冲区
int buff_len=0;///输入句子长度
state action[141][47][2];///语法分析表
production prod[60];///产生式
state got[141][30];///转移函数
///---------SemanticAnalyzer-----------
///---------assignment-----------------
typedef struct{
string type;///(“real““integer““array“)
string array_type;///数组类型
int length;///数组长度
}var_type;
typedef struct id_INFO{
string id;///变量名
var_type type;///变量类型
int addr;///变量地址
id_INFO * next_id;///指向hash表中下一个变量
}id_info;
id_info * id_list[211];
typedef struct{
string name_list[10];///一次支持最多10个变
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 799758 2015-05-21 12:45 SemanticAnalyzer_v2\bin\Debug\SemanticAnalyzer_v2.exe
文件 645 2015-05-21 12:45 SemanticAnalyzer_v2\LexcialOut.txt
文件 145143 2015-05-21 12:45 SemanticAnalyzer_v2\main.cpp
文件 309727 2015-05-21 12:45 SemanticAnalyzer_v2\obj\Debug\main.o
文件 1142 2015-05-14 22:41 SemanticAnalyzer_v2\SemanticAnalyzer_v2.cbp
文件 337 2015-05-21 12:35 SemanticAnalyzer_v2\SemanticAnalyzer_v2.depend
文件 2107 2015-05-17 22:50 SemanticAnalyzer_v2\SemanticAnalyzer_v2.layout
文件 277 2015-05-21 12:45 SemanticAnalyzer_v2\SemanticOut.txt
文件 2068 2015-05-21 12:45 SemanticAnalyzer_v2\SyntaxOut.txt
文件 235 2015-05-21 12:21 SemanticAnalyzer_v2\test.txt
文件 388 2015-05-20 21:07 SemanticAnalyzer_v2\test_all.txt
目录 0 2015-05-21 12:45 SemanticAnalyzer_v2\bin\Debug
目录 0 2015-05-21 12:58 SemanticAnalyzer_v2\obj\Debug
目录 0 2015-05-14 22:42 SemanticAnalyzer_v2\bin
目录 0 2015-05-14 22:42 SemanticAnalyzer_v2\obj
目录 0 2015-05-21 12:58 SemanticAnalyzer_v2
----------- --------- ---------- ----- ----
1261827 16
相关资源
- 编译原理c语言编译器
- C语言编译器的设计与实现.doc
- tiny+编译器C++实现
- 编译原理课程设计-C语言子集编译器
- 一个C语言编译器源码
- 可以将C语言转变为汇编的编译器
- LL1语义分析的C语言子集编译器
- 编译原理简易C编译器
- plo编译器 c语言 含测试 以及实验报告
- picc8.05编译器
- 计算机二级VC++2010学习版
- SNL语言编译器GUI VC++ 2008版 MFC实现可
- winTC(windows下的c语言编译器
- SNL语言编译器C++实现
- MinGW Windows 下gnu C/C++编译器
- sdcc编译器v2.9.0
- C-语言编译器可运行生成汇编代码
- C-Minus编译器
- VC++2010 Express计算机二级考试所用编译
- Borland C++ 5.5 编译器
- Wava 6000 (内有comp86汇编编译器,com
- 经典的编译器gcc2.95.3安装文件已编译
- pl/0语言的编译器
- lex yacc 文献 资料
- dev C++编译器
- 编译原理简单的编译器源码
- C语言实现一个编译器-编译原理南开大
- PL0编译器词法检查与语法分析器
- C语言简化编译器前端 编译原理 LR1
- C-Minus编译器 编译原理实验
评论
共有 条评论