合肥工業大學編譯原理實驗報告(完整代碼版)_第1頁
合肥工業大學編譯原理實驗報告(完整代碼版)_第2頁
合肥工業大學編譯原理實驗報告(完整代碼版)_第3頁
免費預覽已結束,剩余20頁可下載查看

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、計算機與信息學院編譯原理 實驗報告專業班級信息安全 131 班學生姓名及學號馬駿 2013211869課程教學班號任課教師李宏芒實驗指導教師李宏芒實驗地點實驗樓機房20152016 學年第 二 學期實驗1 詞法分析設計、 實驗目得通過本實驗得編程實踐 ,使學生了解詞法分析得任務 ,掌握詞法分析程序設 計得原理與構造方法 ,使學生對編譯得基本概念、原理與方法有完整得與清 楚得理解,并能正確地、熟練地運用、 實驗要求1、編程時注意編程風格 :空行得使用、注釋得使用、縮進得使用等。2、將標識符填寫得相應符號表須提供給編譯程序得以后各階段使用。3、根據測試數據進行測試。測試實例應包括以下三個部分 :

2、全部合法得輸入。各種組合得非法輸入。 由記號組成得句子。4、詞法分析程序設計要求輸出形式 例:輸入 VC+ 語言得實例程序 : If i=0 then n+;a= 3b %); 輸出形式為 :單詞二元序列(單詞種別 ,單詞屬性 )類型位置(行,列)for(1,for )關鍵字(1,1)i( 6,i )標識符(1,2)12( 4,= )關系運算符(1,3)0( 5,0 )常數(1,4)then( 1,then)關鍵字(1,5)n(6,n )標識符(1,6)+ErrorError(1,7)( 2, ; )分界符(1,8)a(6,a )標識符(2,1)=(4,<= )關系運算符(2,2)3bE

3、rrorError(2,4)%ErrorError(2,4)( 2, ) )分界符(2,5)( 2, ; )分界符(2,6)用 VC+/VB/JA VA 語言實現對 C 語言子集得源程序進行詞法分析。 通過 輸 入源程序從左到右對字符串進行掃描與分解 ,依次輸出各個單詞得內部編 碼及單 詞符號自身值 ;若遇到錯誤則顯示“ Error ”,然后跳過錯誤部分繼續顯示 ; 同時 進行標識符登記符號表得管理。 以下就是實現詞法分析設計得主要工作 :(1) 從源程序文件中讀入字符。(2) 統計行數與列數用于錯誤單詞得定位。(3) 刪除空格類字符 ,包括回車、制表符空格。(4) 按拼寫單詞 ,并用(內碼,

4、屬性)二元式表示。 (屬性值 token 得機內 表示 )(5) 如果發現錯誤則報告出錯7(6) 根據需要就是否填寫標識符表供以后各階段使用。四、實驗步驟1、根據流程圖編寫出各個模塊得源程序代碼上機調試。2、編制好源程序后 ,設計若干用例對系統進行全面得上機測試 ,并通過所設計 得詞法分析程序 ;直至能夠得到完全滿意得結果。3、書寫實驗報告 ;實驗報告正文得內容 : 功能描述 :該程序具有什么功能?程序結構描述 :函數調用格式、參數含義、返回值描述、函數功能 ;函數 之間得調用關系圖。詳細得算法描述 (程序總體執行流程圖 ) 。 給出軟件得測試方法與測試結果。實驗總結 (設計得特點、不足、收獲

5、與體會 )。五、實驗截圖 先創建 salary 文件輸入If i=0 then n+; a<= 3b %);六、核心代碼#include<iostream>#include<string>#include<fstream>#include <sstream>using namespace std;const char* salaryfile="salary"const int max=40;string idmax="do","end","for","

6、if","printf","scanf","then","while"/ 關鍵 字表string /分界符表 算數運算符表 關系運算符表smax=",","","(",")","","","+","","*","/","<","<=","=&quo

7、t;string kmax;/ 標識符 string cimax;/ 常數 int fjfpoint=5;/ 分界符表尾 int mathpoint=9;/ 算數運算符表尾 int cipointer=0;/ 常數表尾 int idpointer=0;/ 關鍵字表尾int kpointer=0;/ 標識符表尾 int fjf;/0 不就是分界符 1 就是int rowy=1;/ 識別輸入行位置int rowx=1;/ 識別輸入列位置int outkey=0;/ 打印控制 0 為數字后有字母 其她可以 void searcht(int i,string m)/ 根據已識別得首字母識別字符串 /

8、cout<<"enter searcht!"<<endl;int x;if(i=0)/ 首字符就是字母識別關鍵字/ cout<<" a word!"<<endl; for(x=0;x<max;x+) if(idx=m) cout<<"(1,"<<idx<<")"<<" 關 ("<<rowy<<","<<rowx<<")

9、"<<endl;break;if(x=max)/ 不就是關鍵字再識別標識符 for(x=0;x<max;x+) if(kx=m) cout<<"(6,"<<m<<") "<<" 標 ("<<rowy<<","<<rowx<<")"<<endl;break;if(x=max)/ 標識符表沒有時插入標識符 cout<<"(6,"<

10、;<m<<") "<<" 標 ("<<rowy<<","<<rowx<<")"<<endl;kkpointer=m; kpointer+;if(i=1)/ 識別常數/ cout<<" a number!"<<endl; for(x=0;x<max;x+)鍵字識符識符if(cix=m)cout<<"(5,"<<x<<&quo

11、t;)"<<endl; break;if(x=max)cout<<"(5,"<<m<<") 常數 cicipointer=m; cipointer+; if(i=2)/ 識別 分界符 算數運算符 / cout<<" a signal!"<<endl;for(x=0;x<max;x+)if(sx=m) break; / x;if(x<6) fjf=1; if(x>5&&x<10) if(outkey=1) cout<&l

12、t;"(3,"<<sx<<") ("<<rowy<<","<<rowx<<")"<<endl; outkey=0; fjf=0;if(x>9&&x<max1)if(outkey=1)cout<<"(4,"<<sx<<")("<<rowy<<","<<rowx<<&

13、quot;)"<<endl; outkey=0;("<<rowy<<","<<rowx<<")"<<endl;關系運算符算數運算符關系運算符fjf=0;if(x=max)if(outkey=1)cout<<"ErrorError ("<<rowy<<","<<rowx<<")"<<endl;outkey=0;fjf=0;void wo

14、rdlook(char t,string sn)/ 識別首字符 ,分類識別字符串if(t>=48&&t<=57) searcht(1,sn);else if(t>64&&t<91)|(t>96&&t<123) searcht(0,sn);else searcht(2,sn);void split(string s)/ 分割字符串/ cout<<s<<endl;string nowmax;string sn;int nowpointer=0;int i=0;int x;int sign=2

15、;/ 非法數字標志int diannumber=0;/ 數中點得個數 for(x=0;x<s 、 length;x+)if(sx>64&&sx<91)|(sx>96&&sx<123)|(sx>=48&&sx<=57)|(x>0& &sx=46&&sign=1)/ 判斷數字后跟字母還就是字母后有數字if(i=0) if(sx>=48&&sx<=57) sign=1;else sign=2;elseif(sign=1)if(sx>=48&

16、amp;&sx<=57|sx=46)if(sx=46)if(diannumber=0) diannumber+;else sign=0;else sign=0;i+;if(x=(s 、 length1)sn=s、 substr(xi+1,i);if(i>0)/ cout<<sn<<" i="<<i<<endl;cout<<sn<<" "if(sign=0)/ 數字后有字母得情況Errorcout<<" Error("<<

17、rowy<<","<<rowx<<")"<<endl;else /字母開頭得字符串/cout<<" true"<<endl;wordlook(sn0,sn);rowx+;elseif(x>0&&(sx1>64&&sx1<91)|(sx1>96&&sx1<123)|(sx1>=48&&sx1<=57)/ 遇到分界符運算符 如果前面就是數字或字母sn=s、 sub

18、str(xi,i);if(i>0)/ cout<<sn<<" i="<<i<<endl;cout<<sn<<" "if(sign=0)cout<<" Error Error ("<<rowy<<","<<rowx<<")"<<endl;else/ cout<<" true"<<endl; wordlook

19、(sn0,sn); rowx+;i=0;string ll=s 、substr(x,1);/ 判斷就是運算符還就是分界符 wordlook(sx,ll);if(fjf=0)/ 就是運算符i+;if(sx+1>64&&sx+1<91)|(sx+1>96&&sx+1<123)|(sx+1>=48&&sx+1 <=57)/ 如果后面就是數字或字母sn=s、 substr(xi+1,i);/ cout<<sn<<" 運算符 i="<<i<<endl;c

20、out<<sn<<" "outkey=1;wordlook(sn0,sn);rowx+;i=0;if(fjf=1)if(sx1>64&&sx1<91)|(sx1>96&&sx1<123)|(sx1>=48&&sx1<=57)/ 如 果前面就是數字或字母else if(i>0)sn=s、substr(xi,i);/ cout<<sn<<" 運算符 i="<<i<<endl; cout<<

21、;sn<<" "outkey=1;wordlook(sn0,sn);rowx+;i=0;cout<<sx<<" (2,"<<sx<<") 分 界 符 ("<<rowy<<","<<rowx<<")"<<endl;rowx+;/* if(ll="")rowy+;rowx=1;*/;int mainint x;string instring;/ 讀入一行stri

22、ng sn;/*getline(cin,sn);/ string 帶空格輸入cout<<sn<<endl;char t=sn0;if(t>=48&&t<=57)searcht(1,sn);elseif(t>64&&t<91)|(t>96&&t<123)searcht(0,sn);else searcht(2,sn);*/ifstream inputinput(salaryfile);/ inputfile>>noskipws;if(!inputfile)cout<<

23、;"no file"<<endl;string pp; while(!input) getline(input);istringstream istr(pp);string ppword;while(istr>>ppword)/ 按照空格分割字符串 split(ppword);/*int begin = 0;/ 去掉字符串得所有空格begin = pp 、find(" ",begin); /查找空格在 str 中第一次出現得位置 while(begin != 1) /表示字符串中存在空格pp 、replace(begin, 1,

24、""); / 用空串替換 str 中從 begin 開始得 1 個字 符begin = pp 、find(" ",begin); / 查找空格在替換后得 str 中第一次出現 得位置*/ cout<<"good "<<pp<<endl;/ rowx+;rowy+;/ 換行 rowx=1;return 0;七、實驗總結通過本次試驗使我不僅對詞法分析器有了更深得了解,而且提高了編程能力,希望在以后得學習中可以解決詞法分析更多得問題。實驗 2 LL(1) 分析法、實驗目得通過完成預測分析法得語法分析程序

25、,了解預測分析法與遞歸子程序法得區 別與聯系。使學生了解語法分析得功能 ,掌握語法分析程序設計得原理與構 造方 法,訓練學生掌握開發應用程序得基本方法。有利于提高學生得專業素質,為培養適應社會多方面需要得能力。、實驗要求1、編程時注意編程風格 :空行得使用、注釋得使用、縮進得使用等。2、如果遇到錯誤得表達式 ,應輸出錯誤提示信息。3、對下列文法 ,用 LL(1) 分析法對任意輸入得符號串進行分析 :(1) E>TG(2) G>+TG|TG(3) G>(4) T>FS(5) S>*FS|/FS(6) S>(7) F>(E)(8) F>i三、實驗內容

26、 根據某一文法編制調試 LL ( 1 )分析程序 ,以便對任意輸入得符號串 進行分析。構造預測分析表 ,并利用分析表與一個棧來實現對上述程序設計語言得 分 析程序。分析法得功能就是利用 LL(1) 控制程序根據顯示棧棧頂內容、向前瞧符 號以及 LL(1) 分析表 ,對輸入符號串自上而下得分析過程。四、實驗步驟1、根據流程圖編寫出各個模塊得源程序代碼上機調試。2、編制好源程序后 ,設計若干用例對系統進行全面得上機測試 ,并通過所設計 得 LL(1)分析程序 ;直至能夠得到完全滿意得結果。3、書寫實驗報告 ;實驗報告正文得內容 :寫出 LL(1)分析法得思想及寫出符合 LL(1) 分析法得文法。程

27、序結構描述 :函數調用格式、參數含義、返回值描述、函數功能 ;函數 之間得調用關系圖。詳細得算法描述 (程序執行流程圖 ) 。 給出軟件得測試方法與測試結果。 實驗總結 (設計得特點、不足、收獲與體會 )。五、實驗截圖六、核心代碼#include<iostream> #include<string> using namespace std; string pp;/ 輸出字符串 string hh="rn"/ 換行 const int max=50; int endfumax;/ 終止符序號表 int endfupointer=8; char endf

28、urealmax='+','','*','/','(','i',')','#' int unendfumax; int unendfupointer=5; char unendfurealmax='E','G','T','S','F' string makemathmax="E>TG","G>+TG","G>TG"

29、;,"G>$","T>FS","S>*FS","S>/ FS","S>$","F>(E)","F>i"/0 E>TG,1 G>+TG,2 G>TG,3 G>$,4 T>FS,5 S>*FS,6 S>/FS,7 S>$,8 F>(E),9 F>i /$代表空串string behaviormax=" 初始化 ","POP&quo

30、t;int smarttablemaxmax;/ 分析表int checkendfu(char fu)/ 查終結符序號int x; for(x=0;x<endfupointer;x+) if(endfurealx=fu) break;if(x<endfupointer)return x;else return 1;int checkunendfu(char fu)/ 查非終結符序號int x;for(x=0;x<unendfupointer;x+)if(unendfurealx=fu) break;if(x<unendfupointer)return x;else re

31、turn1;string checkmakemath(int x)/ 查產生式表return makemathx;int checksmarttable(int x,int y)/ 查分析表return smarttablexy;class smartboxpublic:smartboxbox0='#'box1='E'boxpointer=1;void push(char fu)boxpointer+; boxboxpointer=fu;char popchar a=boxboxpointer; if(a!='#')/cout<<&q

32、uot;pop: "<<boxpointer<<""<<a<<endl;/stringstream oss;/*pp=pp+"pop: "char buffermax; sprintf(buffer,"%d",boxpointer); string s=buffer;pp=pp+" " pp=pp+s; pp=pp+hh;*/boxpointer;return a;void check if(checkendfu(boxboxpointer)!=1) cha

33、r a;/ cout<<boxboxpointer<<checkendfu(boxboxpointer)<<" /char buffermax;/sprintf(buffer/pp=pp+boxboxpointer;/ pp=pp+checkendfu(boxboxpointer);/pp=pp+" "a=pop;/ cout<<"out "<<a<<endl;char boxmax;int boxpointer;int main/ TODO: Add extra vali

34、dation here動作 "+hh;/ pp=pp+" 步驟 分析棧 剩余輸入串 所用產生式 /*string s1="sdsfs rnsdfsds"string s3="aaaaaaaaaaaaa" s3=s3+s1;CString s2(s3、c_str);/ CString s2=CString(s1);SetDlgItemText(IDC_EDIT2,s2);/ 用 SetDlgItemText( 文本框 ID,字符串 ),將文 本框得內容設置為字符串得內容、SetDlgItemText(IDC_EDIT2,s2);*/ M

35、essageBox(str);string str;cin>>str;int x,y;for(x=0;x<max;x+) /初始化分析表 99 為錯誤代號 for(y=0;y<max;y+)smarttablexy=99; smarttable04=0;smarttable05=0;smarttable10=1;smarttable11=2;smarttable16=3;smarttable17=3;smarttable24=4;smarttable25=4;smarttable30=7;smarttable31=7;smarttable32=5;smarttable3

36、3=5;smarttable36=7;smarttable37=7;smarttable44=8;smarttable45=9;smartbox mark;char fu;char enterfu;int endfunumber;int unendfunumber;string readyin;string enter;/ cin>>enter;/enter="i+i*i#"enter=str;/enter="(i)#"int count=0;/步驟char buffer1max; sprintf(buffer1,"%d"

37、,count);string s1=buffer1;pp=pp+s1+" "/分析棧for(int qq1=0;qq1<=mark 、 boxpointer;qq1+) pp=pp+mark 、boxqq1;for(qq1=0;qq1<10mark 、 boxpointer;qq1+)pp=pp+" "/剩余輸入棧string jiequ1=enter 、substr(0,enter 、 length); pp=pp+jiequ1;for(int t1=0;t1<20;t1+) pp=pp+" "pp=pp+&quo

38、t;初始化 "+hh;for(x=0;x<enter 、 length;)/步驟count+;char buffermax;sprintf(buffer,"%d",count);string s=buffer;pp=pp+s+" "/分析棧for(int qq=0;qq<=mark 、 boxpointer;qq+)pp=pp+mark 、boxqq;for(qq=0;qq<10mark 、 boxpointer;qq+)pp=pp+" "/剩余輸入棧string jiequ=enter 、 substr(

39、x,enter 、 lengthx); pp=pp+jiequ;for(int t=0;t<x+10;t+) pp=pp+" "enterfu=enterx;/ cout<<"enterfu: "<<enterfu<<endl; mark 、 check; fu=mark 、pop;/ cout<<"fu: "<<fu<<endl; if(fu='#')/&&enterfu='#') / cout<<

40、;"sucessed! over!"<<endl; pp=pp+"sucessed! over!"+hh; break; unendfunumber=checkunendfu(fu); endfunumber=checkendfu(enterfu);/ cout<<unendfunumber<<endl;/ cout<<endfunumber<<endl; if(smarttableunendfunumberendfunumber=99) pp=pp+"error!" bre

41、ak; readyin=makemathsmarttableunendfunumberendfunumber; pp=pp+readyin;for(int ddd=0;ddd<14readyin 、 length;ddd+) pp=pp+" " pp=pp+"POP,PUSH("for(y=readyin 、 length1;y>2;y) pp=pp+readyiny; pp=pp+")"+hh;/ cout<<"readyin: "<<readyin<<endl;

42、int firsttime=0;for(y=readyin 、 length1;y>2;y) / cout<<readyiny<<" " if(readyiny!='$') mark 、push(readyiny); if(firsttime=0) if(checkendfu(readyiny)!=1) /cout<<"now x: "<<x<<"/步驟 count+; char buffermax; sprintf(buffer,"%d",c

43、ount); string s=buffer; pp=pp+s+" "/分析棧for(int qq=0;qq<=mark 、 boxpointer;qq+) pp=pp+mark 、boxqq;for(qq=0;qq<10mark 、 boxpointer;qq+) pp=pp+" "/剩余輸入棧string jiequ=enter 、 substr(x,enter 、 lengthx); pp=pp+jiequ;for(int t=0;t<x+10;t+) pp=pp+" "pp=pp+" GETNEXT

44、(I)"+hh;x+;/ cout<<"next x: "<<x<<" "<<endl; firsttime=1;mark 、 check;/ cout<<endl; / pp=pp+hh; cout<<pp; return 0;/CDialog:OnOK;七、實驗總結 通過本次試驗使我不僅對 ll(1) 分析法有了更深得了解 ,而且提高了編程能 力 ,希望在以后得學習中可以解決自動構造 follow 集得問題。實驗 3 LR(1) 分析法、實驗目得構造 LR(1)分析程序

45、 ,利用它進行語法分析 ,判斷給出得符號串就是否為該文 法識別得句子 ,了解 LR(K) 分析方法就是嚴格得從左向右掃描 ,與自底向上 得語法分析方法。、實驗要求1、編程時注意編程風格 :空行得使用、注釋得使用、縮進得使用等。2、如果遇到錯誤得表達式 ,應輸出錯誤提示信息。3、程序輸入 /輸出實例 : 輸入一以#結束得符號串 (包括+*i#):在此位置輸入符號串 輸出過程如下 :步驟狀態棧符號棧剩余輸入串動作10#i+i*i#移進i+i*i得 LR 分析過程步驟狀態棧 符號棧輸入串動作說明10# i+i*i#ACTION0,i=S5, 狀態 5 入棧205#i+i*i#r6: Fi 歸約 ,G

46、OTO(0,F)=3 入棧303#F+i*i#r4: TF 歸約 ,GOTO(0,T)=3 入棧402#T+i*i#r2: ET 歸約 ,GOTO(0,E)=1 入棧501#E+i*i#ACTION1,+=S6, 狀態 6 入棧6 016 #E+ i*i# ACTION6,i=S5, 狀態 5 入棧7 0165 #E+i *i# r6: F i 歸約,GOTO(6,F)=3 入棧8 0163 #E+F *i# r4: TF 歸約 ,GOTO(6,T)=9 入棧9 0169 #E+T *i# ACTION9,*=S7, 狀態 7 入棧10 01697 #E+T* i# ACTION7,i=S5,

47、 狀態 5 入棧11 016975 #E+T*i # r6:F i 歸約,GOTO(7,F)=10 入棧12 0169710 #E+T*F # r3: TT*F 歸約 ,GOTO(6,T)=9 入棧13 0169 #E+T # r1:EE+T,GOTO(0,E)=1 入棧14 01 #E # Acc: 分析成功三、實驗內容對下列文法 ,用 LR(1)分析法對任意輸入得符號串進行分析 :(1) E> E+T(2) E>T(3) T> T*F(4) T>F(5) F> (E)(6) F> i四、實驗步驟1、根據流程圖編寫出各個模塊得源程序代碼上機調試。2、編制好

48、源程序后 ,設計若干用例對系統進行全面得上機測試 ,并通過所設計 得 LR(1)語法分析程序 ; 直至能夠得到完全滿意得結果。3、書寫實驗報告 ;實驗報告正文得內容 :描述 LR(1)語法分析程序得設計思想。程序結構描述 :函數調用格式、參數含義、返回值描述、函數功能 ;函數之間得調用關系圖。詳細得算法描述 (程序執行流程圖 ) 給出軟件得測試方法與測試結果。五、實驗截圖六、核心代碼#include<iostream>#include<string> using namespace std;int count=1;string pp;/ 輸出字符串string hh=&

49、quot;rn"/ 換行const int max=100;char endfurealmax='i','+','*','(',')','#','E','T','F'int endfupointer=8;string creatwordmax="E>E+T","E>T","T>T*F","T>F","F>(E)",

50、"F>i"/(0)E> E+T(1)E>T (2)T> T*F (3)T>F (4)F> (E) (5)F> i/注意 rj 時 j 應對應數組下標int checkendfu(char fu)/ 查終結符序號int x; for(x=0;x<=endfupointer;x+)if(endfurealx=fu)break; if(x<=endfupointer) return x; else return 1;class actiongo/原子動作 public:actiongo/ cout<<"e

51、roor! wrong action or goto creat"<<endl; actype=4; action(int i,int j) actype=i; number=j;/ cout<<i<<" "<<j<<endl;int actype;/0=s 1=r 2=acc 3=goto 表 4=wrongint number;actiongo smarttablemaxmax;class stylebox/狀態棧public: styleboxbox0=0; boxpointer=0;void pu

52、sh(int style) boxpointer+; boxboxpointer=style;int popint a=boxboxpointer; boxpointer;/cout<<"pop now"<<endl;return a;int boxmax;int boxpointer;class readybox/已歸約棧public: readybox box0='#' boxpointer=0;void push(char fu)boxpointer+; boxboxpointer=fu; char popchar a=boxb

53、oxpointer;boxpointer;return a;char boxmax;int boxpointer;ptr,intint program(stylebox&style,readybox&ready,char fu,int icount,string control)/ 返回就是否需要移進信號 if(control=1)/ char bermax; sprintf(ber,"%d",count); string st=ber; pp=pp+st+" " count+;/pp=pp+" " for(int q

54、q=0;qq<=style 、 boxpointer;qq+) char bssmax;sprintf(bss,"%d",style 、 boxqq); string st=bss; pp=pp+st;for(qq=0;qq<10style 、 boxpointer;qq+) pp=pp+" "for( qq=0;qq<=ready 、boxpointer;qq+) pp=pp+ready 、boxqq;for(qq=0;qq<10ready 、 boxpointer;qq+)pp=pp+" "for(int

55、dj=icount;dj<ptr 、length;dj+)pp=pp+ptrdj;pp=pp+" "/int i=style 、pop;/ 如果就是 s 則狀態還要入棧/ cout<<" 現在狀態 "<<i;int j=checkendfu(fu);if(j=1)pp=pp+"error!"return 4;/wrong!/ cout<<" 現在符號 : "<<fu<<" "<<j<<endl;int ch

56、eckstyle=smarttableij 、actype;/ 查表 if(checkstyle=4)pp=pp+"error!"return 4;/wrong!if(checkstyle=0|checkstyle=3)style、push(i);/ 如果就是 s 則狀態還要入棧 if(checkstyle=0)number<<", 狀 /cout<<"ACTION"<<i<<","<<fu<<"=S"<<smarttab

57、leij 態"<<smarttableij 、 number<<" 入棧 "<<endl; pp=pp+"ACTION"char buffermax;sprintf(buffer,"%d",i);string s=buffer;pp=pp+s;pp=pp+","pp=pp+fu;pp=pp+"=S"char bufmax;sprintf(buf,"%d",smarttableij 、 number); s=buf;pp=pp+s;

58、pp=pp+", 狀態 "pp=pp+s+" 入棧 "+hh;if(checkstyle=3)/ cout<<i<<","<<endfurealj<<")="<<smarttableij 入棧 "<<endl;char bfmax;sprintf(bf,"%d",i);string s=bf;pp=pp+s;pp=pp+","+endfurealj+")="char bfff

59、max; sprintf(bfff,"%d",smarttableij、 number);s=bfff;pp=pp+s+" 入棧 "+hh;ready、push(fu);style、 push(smarttableij 、 number);/cout<<style 、 boxstyle 、boxpointer<<endl;return 1;/ 移進if(checkstyle=1)string l=creatwordsmarttableij 、 number;/ cout<<"r"<<sm

60、arttableij 、 number+1<<": "<<l<<" pp=pp+"r"int dd=smarttableij 、 number+1;char bfcmax;sprintf(bfc,"%d",dd);string ss=bfc;pp=pp+ss+": "+l+" 歸約 ,GOTO("char n;/pop 用得、 number<<"歸約,GOTO("int x;/ cout<<l 、length<<endl;char sq=ready 、pop;for(x=0;x<l 、 leng

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論