




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、1/*/* 2* ÓÃ״̬»úʵÏÖ¶Ô´úÂëÖÐ×¢Ê͵ÄÇå³ý. 3*/ 4 5#include <stdio.h> 6#include <string.h> 7 8#define SCREEN 910void initialize_fsm(char fsm7
2、256);1112int main()1314 int ch , temp = 0 ;15 int state = 0;16 char fsm7256;1718 FILE *pfin ;19 if (pfin = fopen("sweep-comments.txt","r") = NULL)20 21 printf("can not open the file");22 exit(0);23 2425 #ifdef SCREEN26 #define OUT stdout27 #else28 FILE *pfout;29 pfout =
3、 fopen("result.txt","w");30 #define OUT pfout31 #endif3233 initialize_fsm(fsm);3435 #pragma region FSM /*/³¢ÊÔ#pragma region¹¦ÄÜ. Visual C+ 20053637 while (ch = fgetc(pfin) != EOF)38 39 state = fsmstatech;4041 if ( state != 2 && ch
4、!='*' && temp = '/')42 fputc(temp,OUT);4344 temp = ch;4546 switch(state)47 48 /*/*0,5,6Ö´ÐÐͬһ¸ö¶¯×÷*/49 case 5:50 case 6:51 case 0:52 fputc(ch,OUT);53 break;54 case 7:55 state = 0;56 break;57 5859 if(stat
5、e != 1)60 temp=0;61 62 #pragma endregion636465void initialize_fsm(char fsm7256)6667 int lenth = sizeof(char)*256;6869 memset(fsm0,0,lenth);70 memset(fsm1,0,lenth);71 memset(fsm2,2,lenth);72 memset(fsm3,3,lenth);73 memset(fsm4,3,lenth);74 memset(fsm5,5,lenth);75 memset(fsm6,5,lenth);7677 fsm0'&qu
6、ot;' = 5;78 fsm0'/' = 1;79 fsm1'/' = 2;80 fsm1'*' = 3;81 fsm2'n' = 0;82 fsm3'*' = 4;83 fsm4'/' = 7;84 fsm5'' = 6;85 fsm5'"' = 0;8687´úÂë2 1% 2/*/* 3*ÓÃlexʵÏÖÇå³&
7、#253;´úÂë×¢ÊÍ 4*/ 5void comment(int style); 6void string_constant(); 7const int singalline =0, multiline =1; 8 9%101112%1314"/*" comment(multiline );15"/" comment(singalline);16""" string_constant();17.|n fprintf(yyout,"
8、%c",*yytext); 1819%2021int main(int argc,char *argv)2223 FILE *pfin ,*pfout;24 if (pfin = fopen (argv1,"r") =NULL)25 26 printf("can not open the filen");27 exit (1);28 29 pfout = fopen("output.txt","w");30 31 yyin = pfin;32 yyout = pfout;33 34 yylex();353
9、6 return 0;373839void string_constant()4041 int ch ;4243 fprintf(yyout,"%c",*yytext);4445 while ( (ch = input() != EOF)46 47 if (ch = '')48 49 fprintf(yyout,"%c",ch);50 ch = input();51 fprintf(yyout,"%c",ch);52 53 continue;54 5556 if (ch = '"')57 58
10、 fprintf(yyout,"%c",ch);59 break;60 61 62 fprintf(yyout,"%c",ch);63 646566void comment(int style)6768 int ch , prev=0;69 if (style = multiline)70 71 while ( (ch = input() != EOF )72 73 if (prev = '*' && ch = '/')74 return ;7576 prev = ch;77 78 79 return ;80 81 else82 83
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年P(guān)ython模塊化編程探討試題及答案
- DB36-T1555-2021-鐵皮石斛崖壁栽培技術(shù)規(guī)程-江西省
- 能源系統(tǒng)培訓
- 2025年建設工程造價管理注冊造價工程師考試模擬試卷全攻略
- USACO2024-202美國計算機奧林匹克競賽編程模擬試卷(算法與數(shù)據(jù)結(jié)構(gòu))競賽解析指南
- 護理教學課程體系構(gòu)建
- 腦梗塞介入治療
- 法語DELFB1寫作口語押題卷(2025年必做模板)
- 2025年鄉(xiāng)村醫(yī)生考試題庫:農(nóng)村醫(yī)療衛(wèi)生服務體系基層衛(wèi)生服務試題
- 高頻考點版2025年中級社會工作師綜合能力沖刺試卷(含方案設計)
- 2025-2030年中國威士忌酒行業(yè)運行動態(tài)及前景趨勢預測報告
- 小學生記憶小竅門課件
- 婚姻家庭與法律知到智慧樹章節(jié)測試課后答案2024年秋延邊大學
- 物業(yè)管理安全責任分配
- 《傷寒論》課件-少陽病提綱、小柴胡湯證
- 中國鐵路沈陽局集團有限公司招聘筆試沖刺題2025
- 2024年度醫(yī)療設備報廢回收與資源化利用合同3篇
- 2024商鋪租賃合同解除補償承諾書11篇
- 科室病歷質(zhì)量管理培訓記錄
- 新興行業(yè)審計風險分析-洞察分析
- 《口腔頜面醫(yī)學影像診斷學》考試復習題庫(含答案)
評論
0/150
提交評論