资源简介
课设得了优 :-)
编译原理的课程设计SLR(1)分析器
包含求FIRST,FOLLOW集合 LR(0)项目规范集组
SLR(1)分析表 SLR(1)分析器

代码片段和文件信息
#include
#include
using namespace std;
const int maxn=100;
const int ERROR=1000000000;
int binary[31]={12481632641282565121024204840968192
163843276865536131072262144524288104857620971524194304
83886081677721633554432671088641342177282684354565368709121073741824};
struct G
{
char left;
char right[100];
int l;
}g[maxn];
struct G_EXTEND
{
char left;
char right[100];
int l;
int dot_pos;
}g_extend[maxn*maxn];
struct C
{
int item[maxn];
bool mark[maxn];
int l;
}c[maxn];
int c_len;
char Vt[maxn]Vn[maxn]Vhash[128];
int g_cntvt_cntvn_cntg_extend_cnt;
int first_v[128];
int go[maxn][128];
struct FLO
{
int t;
int start;
}follow[128];
int ACTION[maxn*maxn][128]GOTO[maxn*maxn][128];
int State_S[maxn];
char Sign_S[maxn]a[maxn];
void FIRST()
{
bool visited[maxn]changed[128];
memset(first_v0sizeof(first_v));
for(int i=0;i {
first_v[Vt[i]]+=binary[i];
}
int flag;
while(1)
{
flag=0;
for(int i=0;i {
// cout<“< // cout< if(g[i].left!=g[i].right[0] && first_v[g[i].right[0]] && !(first_v[g[i].left]&first_v[g[i].right[0]]) )
{
first_v[g[i].left]+=first_v[g[i].right[0]];
flag=1;
}
}
if(!flag) break;
}
/* for(int i=0;i {
for(int ii=0;ii<31;ii++)
if(first_v[Vn[i]]&binary[ii]) cout< cout< }*/
}
void FOLLOW()
{
FIRST();
memset(follow0sizeof(follow));
follow[Vn[0]].start=1;
for(int i=0;i {
for(int j=0;j if(!(follow[g[i].right[i]].t&first_v[g[i].right[j+1]]))
{
follow[g[i].right[j]].t+=first_v[g[i].right[j+1]];
if(follow[g[i].right[j+1]].start) follow[g[i].right[j]].start=follow[g[i].right[j+1]].start;
}
}
/* for(int i=0;i {
cout< for(int j=0;j<31;j++) if(follow[Vn[i]].t&binary[j]) cout< if(follow[Vn[i]].start) cout<<“# “;
cout< }*/
while(1)
{
int flag=0;
for(int i=0;i if(g[i].right[g[i].l-1]>=‘A‘ && g[i].right[g[i].l-1]<=‘Z‘)
{
if( follow[g[i].left].t && !(follow[g[i].right[g[i].l-1]].t&follow[g[i].left].t))
{
flag=1;
follow[g[i].right[g[i].l-1]].t+=follow[g[i].left].t;
}
else if(follow[g[i].left].start==1&&follow[g[i].right[g[i].l-1]].start==0)
{
flag=1;
follow[g[i].right
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
.CA.... 44 2008-12-07 16:05 SLR(1)\1.in
.CA.... 910 2008-12-08 17:10 SLR(1)\DATA.h
.CA.... 5676 2008-12-08 22:06 SLR(1)\Debug\BuildLog.htm
.CA.... 67 2008-12-08 22:06 SLR(1)\Debug\mt.dep
.CA.... 172032 2008-12-08 22:06 SLR(1)\Debug\SLR(1).exe
.CA.... 145 2008-12-08 22:06 SLR(1)\Debug\SLR(1).exe.intermediate.manifest
.CA.... 229984 2008-12-08 22:06 SLR(1)\Debug\SLR.obj
.CA.... 93184 2008-12-08 22:06 SLR(1)\Debug\vc80.idb
.CA.... 1781 2008-12-08 17:23 SLR(1)\FOLLOW.h
.CA.... 133 2008-12-08 22:45 SLR(1)\FOLLOW.txt
.CA.... 74 2008-12-08 22:45 SLR(1)\G.txt
.CA.... 231 2008-12-08 22:45 SLR(1)\G_extend.txt
.CA.... 1219 2008-12-08 21:12 SLR(1)\INIT.h
.CA.... 386 2008-12-08 22:45 SLR(1)\LR(0)Set.txt
.CA.... 3910 2008-12-08 21:26 SLR(1)\LR0Set.h
.CA.... 5300 2008-12-08 22:02 SLR(1)\SHOW.h
.CA.... 15072 2008-12-08 01:08 SLR(1)\slr(1).cpp
.CA.... 1395712 2008-12-08 23:17 SLR(1)\SLR(1).ncb
.CA.... 876 2008-12-08 16:27 SLR(1)\SLR(1).sln
.CA..H. 15360 2008-12-08 23:17 SLR(1)\SLR(1).suo
.CA.... 3452 2008-12-08 21:13 SLR(1)\SLR(1).vcproj
.CA.... 1427 2008-12-08 23:17 SLR(1)\SLR(1).vcproj.PC-200811121904.Administrator.user
.CA.... 510 2008-12-08 22:45 SLR(1)\SLR(1)Grid.txt
.CA.... 410 2008-12-08 21:33 SLR(1)\SLR.cpp
.CA.... 2443 2008-12-08 17:51 SLR(1)\SLR1Grid.h
.CA.... 1637 2008-12-08 22:06 SLR(1)\SLRDFA.h
.C.D... 0 2008-12-08 22:06 SLR(1)\Debug
.C.D... 0 2008-12-08 23:17 SLR(1)
----------- --------- ---------- ----- ----
1951975 28
............此处省略1个文件信息
相关资源
- FTP课程设计(服务端+客户端)
- 编译原理实验工具及参考源码(lex&
- 类pascal语言编译器(编译原理实验)
- 高频电子线路课程设计报告收音机
- 直流稳压电源的课程设计、安装及调
- EDA课程设计_密码锁
- 单片机课程设计 篮球计分器
- 数据结构课程设计 6 1 彩票系统
- 端口扫描课程设计详细的报告
- 步进电机课程设计(个人设计)
- 校园网络规划与设计课程设计
- 编译原理课程设计:词法语法编译器
-
simuli
nk 课程设计 qpsk - 武汉理工大学 单片机课程设计 16*16点
- 数据库VFP课程设计
- 分页系统模拟实验 操作系统 课程设
- 中科院 编译原理 习题及解答
- 编译原理四元式和逆波兰式
- 模拟段页式虚拟存储管理中地址转换
- 硬件课程设计—流水灯(quartus软件
- 超市收银系统eclipse access大学课程设计
- 航空订票系统_数据结构课程设计
- c 课程设计 职工信息管理系统
- 汇编语言,课程设计,红绿灯
- 机床液压系统课程设计卧式钻床动力
- 课程设计蔬菜大棚自动控制系统,包
- 密码学课程设计:DES加密解密算法的
- 操作系统课程设计完整版
- 磁盘调度算法的模拟实现及对比
- 《编译原理》清华大学版中的pl0扩充
评论
共有 条评论