xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 242KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-08-12
  • 語言: 其他
  • 標簽: 編譯原理??

資源簡介

借助于詞法分析程序提供的分析結果,編寫一個算符優先語法分析程序,程序能進行語法結構分析和錯誤檢查,并產生相應的歸約信息。同時給出出錯信息和錯誤類型,從而加深對語法分析的理解。

資源截圖

代碼片段和文件信息

#include
#include
#include
#include
#include
#include
using?namespace?std;
struct?token//token結構體
{
int?code;
int?num;
token?*next;
};
token?*token_head*token_tail;//token隊列
struct?number//number結構體
{
int?num;
int?value;
number?*next;
};
number?*number_head*number_tail;//number隊列
struct?str//string結構體
{
int?num;
string??word;
str?*next;
};
str?*string_head*string_tail;//string隊列
struct?ivan//表達式結構體
{
char?left;
string?right;
int?len;
};
ivan?css[20];//20個表達式
struct?pank//action表結構體
{
char?sr;
int?state;
};
pank?action[46][18];//action表
int?go_to[46][11];//go_to表
struct?ike//分析棧結構體,雙鏈
{
ike?*pre;
int?num;
int?word;
ike?*next;
};
ike?*stack_head*stack_tail;//分析棧首尾指針

void?scan();//按字符讀取源文件
int?judge(char?ch);//判斷輸入字符的類型
void?out1(char?ch);//寫入token.txt
void?out2(char?chstring?word);//寫入number.txt
void?out3(char?chstring?word);//寫入string.txt
void?input1(token?*temp);//插入結點到隊列token
void?input2(number?*temp);//插入結點到隊列number
void?input3(str?*temp);//插入結點到隊列string
void?output();//輸出三個隊列的內容
void?outfile();//輸出三個隊列的內容到相應文件中
void?yufa_initialize();//初始化語法分析數據結構
int?yufa_main(int?a);//語法分析主體部分
int?ID1(int?a);//給輸入字符編號,轉化成action表列編號
string?ID10(int?i);//給輸入字符反編號
int?ID2(char?ch);//給非終結狀態編號,轉化成go_to表列編號
int?ID20(char?ch);//給非終結狀態編號
char?ID21(int?j);//給非終結狀態反編號
void?add(ike?*temp);//給ike分析棧鏈表增加一個結點
void?del();//給ike分析棧鏈表刪除一個結點

FILE?*fp;//文件
int?wordcount;//標志符計數
int?numcount;//整型常數計數
int?err;//標志詞法分析結果正確或錯誤
int?nl;//讀取行數
void?main()
{
token_head=new?token;
token_head->next=NULL;
token_tail=new?token;
token_tail->next=NULL;
number_head=new?number;
number_head->next=NULL;
number_tail=new?number;
number_tail->next=NULL;
string_head=new?str;
string_head->next=NULL;
string_tail=new?str;
string_tail->next=NULL;//初始化三個隊列的首尾指針
wordcount=0;//初始化字符計數器
numcount=0;//初始化常數計數器
err=0;//初始化詞法分析錯誤標志
nl=1;//初始化讀取行數
scan();
if(err==0)
{
char?m;
cout<<“詞法分析正確完成!“< cin>>m;
output();
if(m==‘y‘)
{
cout<<“結果同時保存在token.txt、number.txt和sting.txt三個文件中,請打開查看“< outfile();
}
}
yufa_initialize();//初始化語法分析數據結構
token?*temp;
temp=new?token;
temp=token_head->next;
int?pq;
p=0;
q=0;
cout< while(temp!=NULL)
{
int?w;
w=ID1(temp->code);
p=yufa_main(w);
if(p==1)?break;
if(p==0)
temp=temp->next;
if(temp==NULL)?q=1;
}//語法分析
if(q==1)
while(1)
{
p=yufa_main(17);
if(p==3)?break;
}//最后輸入$來完成語法分析
cout< system(“pause“);
}
void?scan()
{
char?ch;
string?word;
char?document[50];
int?flag=0;
cout<<“請輸入源文件路徑及名稱:“;
cin>>document;
cout< if((fp=fopen(document“rt“))==NULL)
{
err=1;
cout<<“無法找到該文件!“< return;
}
while(!feof(fp))
{
word=““;
ch=fgetc(fp);
flag=judge(ch);
if(flag==1)
out1

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????3963??2005-06-15?10:52??語法分析2002112105\SS.clw

?????文件?????115712??2005-06-15?11:06??語法分析2002112105\SS.ncb

?????文件???????4215??2005-06-14?02:13??語法分析2002112105\ReadMe.txt

?????文件???????3409??2005-06-14?15:19??語法分析2002112105\SS.cpp

?????文件???????1054??2005-06-14?02:13??語法分析2002112105\StdAfx.h

?????文件????????204??2005-06-14?02:13??語法分析2002112105\StdAfx.cpp

?????文件???????1384??2005-06-14?15:19??語法分析2002112105\SS.h

?????文件??????49664??2005-06-15?11:06??語法分析2002112105\SS.opt

?????文件???????1298??2005-06-15?10:51??語法分析2002112105\SS.plg

?????文件???????6031??2005-06-15?09:03??語法分析2002112105\SS.dsp

?????文件???????1431??2005-06-14?12:09??語法分析2002112105\SSDoc.h

?????文件???????1738??2005-06-14?02:13??語法分析2002112105\SSDoc.cpp

?????文件????????524??2005-06-15?10:55??語法分析2002112105\Test.pl0

?????文件???????1096??2005-06-15?09:16??語法分析2002112105\Resource.h

?????文件????????529??2005-06-14?02:34??語法分析2002112105\SS.dsw

?????文件????????381??2005-06-14?16:59??語法分析2002112105\MFC469.tmp

?????文件????????387??2005-06-14?17:00??語法分析2002112105\MFC163.tmp

?????文件???????2454??2001-10-06?21:44??語法分析2002112105\ColorPicker.h

?????文件????????387??2005-06-14?17:00??語法分析2002112105\MFC46C.tmp

?????文件???????1397??2005-06-14?16:36??語法分析2002112105\SetDlg.h

?????文件?????479313??2005-06-15?10:51??語法分析2002112105\編譯器.exe

?????文件???????1576??2005-06-14?16:05??語法分析2002112105\SourceEditView.h

?????文件???????1928??2005-06-14?16:12??語法分析2002112105\SSView.h

?????文件??????14227??2005-06-15?09:16??語法分析2002112105\SS.rc

?????文件???????1182??2005-06-14?15:17??語法分析2002112105\Logo.cpp

?????文件??????74949??2005-01-05?08:01??語法分析2002112105\OfficeXPMenu.cpp

?????文件??????10680??2005-01-05?07:54??語法分析2002112105\OfficeXPMenu.h

?????文件????????832??2005-06-14?15:17??語法分析2002112105\Logo.h

?????文件???????1229??2005-06-14?13:47??語法分析2002112105\LogoDlg.h

?????文件????????993??2005-06-14?13:47??語法分析2002112105\LogoDlg.cpp

............此處省略29個文件信息

評論

共有 條評論