資源簡介
簡單的C編譯器,為課程設計,僅供參考,歡迎拷貝!!

代碼片段和文件信息
#include“global.h“
#include“parse.h“
#include“util.h“
#include“scan.h“
#define?NO_PARSE?FALSE
int?lineno=0;
FILE?*sourcefile;??????????//???輸入文件存放要編譯的代碼
FILE?*listingfile;?????????//???listing?文件存放scan后的Token和Parse樹
FILE?*codefile;????????????//???code?file存放生產的代碼
char?global_scope[255];????//?范圍變量,控制變量在程序中的范圍
int?EchoSource=TRUE;
int?TraceScan=TRUE;
int?TraceParse=TRUE;
int?TraceAnalyze=TRUE;
int?TraceCode=TRUE;
int?Error=FALSE;
int?main(int?argcchar?*?argv[])
{
TreeNode?*?syntaxTree;
char?pgm[20]=“in“;
char?pgm2[20]=“out“;
/* if(argc!=3)
{
fprintf(stderr“usage:?%s??\n“argv[0]);
exit(1);
}*/
// strcpy(pgmargv[1]);
// strcpy(pgm2argv[2]);
if(strchr(pgm‘.‘)==NULL)
strcat(pgm“.txt“);
if(strchr(pgm2‘.‘)==NULL)
strcat(pgm2“.txt“);
sourcefile=fopen(pgm“r“);
listingfile=fopen(pgm2“w“);
fprintf(listingfile“GetTokening?from?%s?:\n\n“pgm);
/*TokenType?token;
token=getToken();
printf(“%d\n“token);*/
#if?!NO_PARSE
while(getToken().type!=ENDFILE);
#else
fprintf(listingfile“parse......................\n“);
syntaxTree=parse();
// printf(“%d\n“syntaxTree->name);
fprintf(listingfile“\nsyntaxtree........\n\n\n“);
printTree(syntaxTree);
#endif
/* TokenType?token=RETURN;
char?tokenString[20];
strcpy(tokenString“return“);
TreeNode?*t;
t=newExpNode(OpKtokentokenString);
printTree(t);*/
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????112??2008-05-09?15:50??MyCMinus\Debug\in.txt
?????文件???????5418??2008-06-28?18:07??MyCMinus\Debug\main.obj
?????文件?????204856??2008-06-28?18:07??MyCMinus\Debug\MyCMinus.exe
?????文件?????221496??2008-06-28?18:07??MyCMinus\Debug\MyCMinus.ilk
?????文件?????238104??2008-06-28?18:07??MyCMinus\Debug\MyCMinus.pch
?????文件?????508928??2008-06-28?18:07??MyCMinus\Debug\MyCMinus.pdb
?????文件????????542??2008-06-28?18:11??MyCMinus\Debug\out.txt
?????文件??????40828??2008-05-09?15:47??MyCMinus\Debug\parse.obj
?????文件??????15015??2008-05-09?15:47??MyCMinus\Debug\scan.obj
?????文件??????30028??2008-05-09?15:55??MyCMinus\Debug\util.obj
?????文件??????41984??2008-06-28?18:07??MyCMinus\Debug\vc60.idb
?????文件??????53248??2008-06-28?18:07??MyCMinus\Debug\vc60.pdb
?????文件???????3043??2008-05-09?15:46??MyCMinus\global.h
?????文件?????????93??2008-05-09?15:39??MyCMinus\in.txt
?????文件???????1499??2008-06-28?18:07??MyCMinus\main.cpp
?????文件???????4727??2008-05-08?15:40??MyCMinus\MyCMinus.dsp
?????文件????????541??2008-05-08?14:45??MyCMinus\MyCMinus.dsw
?????文件??????58368??2008-06-28?18:08??MyCMinus\MyCMinus.ncb
?????文件??????48640??2008-06-28?18:08??MyCMinus\MyCMinus.opt
?????文件???????1423??2008-06-28?18:07??MyCMinus\MyCMinus.plg
?????文件????????377??2008-06-28?18:07??MyCMinus\out.txt
?????文件??????18361??2008-05-09?15:27??MyCMinus\parse.cpp
?????文件????????110??2008-05-08?15:07??MyCMinus\parse.h
?????文件???????6892??2008-05-09?15:47??MyCMinus\scan.cpp
?????文件????????366??2008-05-08?14:53??MyCMinus\scan.h
?????文件???????7593??2008-05-09?15:55??MyCMinus\util.cpp
?????文件????????801??2008-05-08?15:30??MyCMinus\util.h
?????目錄??????????0??2008-06-28?18:11??MyCMinus\Debug
?????目錄??????????0??2008-06-28?18:08??MyCMinus
-----------?---------??----------?-----??----
............此處省略2個文件信息
評論
共有 條評論