云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 编译原理-LL(1)文法源代码(实验三)

编译原理-LL(1)文法源代码(实验三)

  • 62 次阅读
  • 3 次下载
  • 2025/5/6 9:41:23

pt = pt->next; } } else {

if(0 == kind) {

pt = follow[nCh - 100]; while(NULL != pt) {

ch = pt->nVt;

AddFollow(V, ch, 0); pt = pt->next; } } else {

pt = first[nCh - 100]; while(NULL != pt) {

ch = pt->nVt; if(-1 != ch) {

AddFollow(V, ch, 1); }

pt = pt->next; } } } }

/*输出first或follow集*/

void ShowCollect(struct collectNode **collect) { int i;

struct collectNode *pt; i = 0;

while(NULL != collect[i]) {

pt = collect[i];

printf(\ while(NULL != pt) {

if(-1 != pt->nVt) {

printf(\ } else

printf(\ pt = pt->next; } i++; }

printf(\}

/*计算first和follow*/ void FirstFollow() { int i; i = 0;

while('\\0' != Vn[i]) {

if(NULL == first[i]) First(100 + i); i++; } i = 0;

while('\\0' != Vn[i]) {

if(NULL == follow[i]) Follow(100 + i); i++; } }

/*构造预测分析表*/ void CreateAT() { int i;

struct pRNode *pt; struct collectNode *ct; for(i = 0; i < PNum; i++) {

pt = P[i].rHead;

while(NULL != pt && HaveEmpty(pt->rCursor)) {

ct = first[pt->rCursor - 100]; while(NULL != ct) {

if(-1 != ct->nVt)

analyseTable[P[i].lCursor - 100][ct->nVt] = i; ct = ct->next; }

pt = pt->next; }

if(NULL == pt) {

ct = follow[P[i].lCursor - 100]; while(NULL != ct) {

if(-1 != ct->nVt)

analyseTable[P[i].lCursor - 100][ct->nVt] = i; else

analyseTable[P[i].lCursor - 100][vtNum] = i; ct = ct->next; } } else {

if(100 <= pt->rCursor) /*不含空的非终结符*/ {

ct = first[pt->rCursor - 100]; while(NULL != ct) {

analyseTable[P[i].lCursor - 100][ct->nVt] = i; ct = ct->next; } }

else /*终结符或者空*/ {

if(-1 == pt->rCursor) {

ct = follow[P[i].lCursor - 100]; while(NULL != ct) {

if(-1 != ct->nVt)

analyseTable[P[i].lCursor - 100][ct->nVt] = i; else /*当含有#号时*/

analyseTable[P[i].lCursor - 100][vtNum] = i; ct = ct->next; } }

else /*为终结符*/ {

analyseTable[P[i].lCursor - 100][pt->rCursor] = i; } } } } }

/*输出分析表*/ void ShowAT() {

int i,j;

printf(\构造预测分析表如下:\\n\ printf(\

for(i = 0; i < vtNum; i++) {

printf(\ }

printf(\

printf(\

for(i = 0; i <= vtNum; i++) printf(\ printf(\

for(i = 0; i < vnNum; i++) {

printf(\ for(j = 0; j <= vtNum; j++) {

if(-1 != analyseTable[i][j])

printf(\ else

printf(\ }

printf(\ } }

void Identify(char *st) {

int current,step,r; /*r表使用的产生式的序号*/ printf(\的分析过程:\\n\

搜索更多关于: 编译原理-LL(1)文法源代码(实验三) 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

pt = pt->next; } } else { if(0 == kind) { pt = follow[nCh - 100]; while(NULL != pt) { ch = pt->nVt; AddFollow(V, ch, 0); pt = pt->next; } } else { pt = first[nCh - 100]; while(NULL != pt) { ch = pt->nVt; if(-1 != ch) { AddFollow(V, ch, 1); } pt = pt->next; }

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com