📄 main.cpp
字号:
#include "list.h"
#include "global.h"
#include <iostream.h>
#include <string.h>
//----------------------------------------------------------------------------------------------//
// main函数部分
//包括全局变量的实现,以及源文件的输入和用户界面的提供等
//----------------------------------------------------------------------------------------------//
//**********************************************************************************************//
// 全局变量的实现、初始化(声明在global.h中)
//*********************************************************************************************//
int off;
int lookahead;
char Typename[SIZE];
int ConstVal;
char Constname[SIZE];
char ch;
char token[SIZE];
FILE* testfile;
char errortype[SIZE];
int rightvar;
int leftvar;
int parameterth;
int errorcount=0;
int LINE=1;
type_list typelist[SIZE];
proc_list* cur_proc=new proc_list;
var_list* cur_varlist=new var_list;
proc_list* proc=new proc_list;
var_list* var=new var_list;
field_table* field=new field_table;
int pfollow=0;
int typecount=4;//initial is new type
int VarType=-1;
char progname[SIZE];
void loadprogram();
void program();
void main()
{
char filename[SIZE];
char objname[SIZE];
char c;
cout<<" *********************************************************"<<endl<<endl;
cout<<" Welcome to robin's compiler for minpascal!"<<endl<<endl;
cout<<" **********************************************************"<<endl;
cout<<"Please input the name of source file( .pas ) and press ENTER:"<<endl;
cin>>filename;
if((testfile=fopen(filename,"r"))==NULL)
{
cout<<"Sorry!cannot open source file..."<<endl;
return;
}
strcpy(progname,filename);
program();
for(int i=0;filename[i]!='.';i++)
objname[i]=filename[i];
for(;i<SIZE;i++)
objname[i]=0;
strcat(objname,".obj");
cout<<"compiling complete!"<<endl;
cout<<objname<<" - "<<errorcount<<" error(s)"<<endl;
if(errorcount>0) return;
cout<<"would you like to run "<<objname<<" right now?(y|n)"<<endl;
cin>>c;
if(c=='y'||c=='Y')
{
loadprogram();//
cout<<"end of execution!"<<endl<<endl;
}
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -