-
大小: 34.39MB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2024-01-31
- 語言: 其他
- 標(biāo)簽: 編譯原理??課程設(shè)計(jì)??語法分析??詞法分析??
資源簡(jiǎn)介
包含詞法分析,語法分析,語義分析,中間代碼產(chǎn)生,目標(biāo)代碼產(chǎn)生(C或者masm ) 初始語言為抽象語言,每個(gè)模塊都有單獨(dú)源碼和exe文件,使用不同語言,自行選擇所需模塊
代碼片段和文件信息
#include?
#include?
#include?
using?namespace?std;
struct?Tree
{
char?string[40];
struct?Tree?*?child;
struct?Tree?*?brother;
struct?Tree?*?nextaction;
}*?head*p[10000];//語法樹的定義
struct?quad
{
char?result[8];
char?string[40];
}q[10000];//生成的三地址代碼
int?qnum=0;
char?word[20];
struct?Tree?*?TT;
char?filepath[200];
char?*?newtemp()?//建立一個(gè)新的節(jié)點(diǎn)
{
char?*p;
p=new?char[8];
char?x[10];
int?t=qnum;
int?i=1;
p[0]=‘T‘;
itoa(tx10);
for(int?j=0;x[j]!=‘\0‘;i++j++)
p[i]=x[j];
p[i]=‘\0‘;
return?p;
}
void?Getfirstword(char?str[])//獲取一個(gè)字符串中的第一個(gè)單詞(只在分析read時(shí)調(diào)用)
{
int?i=0j=0;
while(str[j]==‘?‘)
{
j++;
}
while(str[j]!=‘?‘&&str[j]!=‘\0‘)
{
word[i]=str[j];
i++;
j++;
}
word[i]=‘\0‘;
}
char?*?explain(struct?Tree?*t)//分析語法生成樹
{
char?*?p=new?char[40];
char?string[40];
int?num=qnumcount=qnumtem;
Getfirstword(t->string);
if(!strcmp(word“read“))//分析read
{
strcpy(q[num].resultnewtemp());
qnum++;
strcpy(pq[num].result);
strcpy(q[num].stringt->string);
if(t->nextaction!=NULL)
explain(t->nextaction);
}
else?if(!strcmp(t->string“write“))//分析write
{
strcpy(stringexplain(t->child));
num=qnum;
strcpy(q[num].resultnewtemp());
qnum++;
strcpy(pstring);
strcpy(q[num].string“write?“);
strcat(q[num].stringstring);
if(t->nextaction!=NULL)
explain(t->nextaction);
}
else?if(!strcmp(t->string“if“))//分析if
{
strcpy(stringexplain(t->child));
num=qnum;
strcpy(q[num].resultnewtemp());
qnum++;
strcpy(pq[num].result);
strcpy(q[num].string“if?“);
strcat(q[num].stringstring);
strcat(q[num].string“?goto?“);
strcat(q[num].stringnewtemp());
explain(t->child->brother);
if(t->child->brother->brother!=NULL)
{
strcpy(q[qnum].resultnewtemp());
tem=qnum;
qnum++;
strcat(q[num].string“?else?goto?“);
????strcat(q[num].stringnewtemp());
explain(t->child->brother->brother);
strcpy(q[tem].string“goto?“);
strcat(q[tem].stringnewtemp());
}
else?
{
strcat(q[num].string“?else?goto?“);
????strcat(q[num].stringnewtemp());
}
if(t->nextaction!=NULL)
explain(t->nextaction);
}
else?if(!strcmp(t->string“<“)||!strcmp(t->string“=“))//分析<和=
{
strcpy(pexplain(t->child));
strcat(pt->string);
strcat(pexplain(t->child->brother));
}
else?if(!strcmp(t->string“+“)||!strcmp(t->string“-“)||!strcmp(t->string“*“)||!strcmp(t->string“/“))//分析+-*/
{
strcpy(pq[num].result);
strcat(pexplain(t->child));
strcat(p“?“);
strcat(pt->string);
strcat(p“?“);
strcat(pexplain(t->child->brother));
strcpy(q[qnum].resultnewtemp());
strcpy(q[qnum].stringp);
strcpy(pq[qnum].result);
qnum++;
}
else?if(!strcmp(t->string“repeat“))//分析repeat
{
strcpy(pexplain(t->child));
strcpy(stringexplain(t->child->brother));
num=qnum;
strcpy(q[num].resultnewtemp());
qnum++;
strcp
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????????0??2013-12-18?13:35??編譯原理\應(yīng)用程序\cd
?????文件??????????0??2013-12-18?13:35??編譯原理\應(yīng)用程序\copy
?????文件????????125??2014-01-09?16:35??編譯原理\應(yīng)用程序\eg1.txt
?????文件?????????75??2014-01-09?13:46??編譯原理\應(yīng)用程序\eg2.txt
?????文件?????860672??2013-12-06?09:41??編譯原理\應(yīng)用程序\ffmpegsumo.dll
?????文件????9956864??2013-12-06?09:41??編譯原理\應(yīng)用程序\icudt.dll
?????文件?????102400??2013-12-06?09:41??編譯原理\應(yīng)用程序\libEGL.dll
?????文件?????873984??2013-12-06?09:41??編譯原理\應(yīng)用程序\libGLESv2.dll
?????文件????4000679??2013-12-06?09:41??編譯原理\應(yīng)用程序\nw.pak
?????文件????4208128??2013-12-06?09:41??編譯原理\應(yīng)用程序\nwsnapshot.exe
?????文件????????482??2014-01-10?11:25??編譯原理\應(yīng)用程序\readme.txt
?????文件???39791563??2014-01-10?09:28??編譯原理\應(yīng)用程序\Tiny.exe
?????文件???????6122??2014-01-10?22:18??編譯原理\源程序\中間代碼產(chǎn)生\qiuming.cpp
?????文件???????4296??2014-01-10?22:19??編譯原理\源程序\中間代碼產(chǎn)生\qiuming.dsp
?????文件????????520??2014-01-10?22:17??編譯原理\源程序\中間代碼產(chǎn)生\qiuming.dsw
?????文件??????33792??2014-01-10?22:19??編譯原理\源程序\中間代碼產(chǎn)生\qiuming.ncb
?????文件??????48640??2014-01-10?22:18??編譯原理\源程序\中間代碼產(chǎn)生\qiuming.opt
?????文件????????248??2014-01-10?22:18??編譯原理\源程序\中間代碼產(chǎn)生\qiuming.plg
?????文件????????224??2014-01-10?22:18??編譯原理\源程序\中間代碼產(chǎn)生\qiuming.txt
?????文件????????891??2014-01-05?22:11??編譯原理\源程序\中間代碼產(chǎn)生\tree.txt
?????文件???45678592??2014-01-09?23:12??編譯原理\源程序\目標(biāo)代碼產(chǎn)生\ipch\renurncomplex-f8a982de\renurncomplex-a86f33e.ipch
?????文件????????600??2014-01-09?23:14??編譯原理\源程序\目標(biāo)代碼產(chǎn)生\RenurnCOmplex\Debug\cl.command.1.tlog
?????文件??????22066??2014-01-09?23:14??編譯原理\源程序\目標(biāo)代碼產(chǎn)生\RenurnCOmplex\Debug\CL.read.1.tlog
?????文件????????384??2014-01-09?23:14??編譯原理\源程序\目標(biāo)代碼產(chǎn)生\RenurnCOmplex\Debug\CL.write.1.tlog
?????文件?????336390??2014-01-09?23:14??編譯原理\源程序\目標(biāo)代碼產(chǎn)生\RenurnCOmplex\Debug\Decompiler.obj
?????文件???????1246??2014-01-09?23:14??編譯原理\源程序\目標(biāo)代碼產(chǎn)生\RenurnCOmplex\Debug\li
?????文件???????2504??2014-01-09?23:14??編譯原理\源程序\目標(biāo)代碼產(chǎn)生\RenurnCOmplex\Debug\li
?????文件????????658??2014-01-09?23:14??編譯原理\源程序\目標(biāo)代碼產(chǎn)生\RenurnCOmplex\Debug\li
?????文件????????488??2014-01-09?23:14??編譯原理\源程序\目標(biāo)代碼產(chǎn)生\RenurnCOmplex\Debug\mt.command.1.tlog
?????文件???????1124??2014-01-09?23:14??編譯原理\源程序\目標(biāo)代碼產(chǎn)生\RenurnCOmplex\Debug\mt.read.1.tlog
............此處省略73個(gè)文件信息
評(píng)論
共有 條評(píng)論