int main(int argc, char *argv[])
{
char command[10], filename[200];
int load=0;
InitSystem();
while(1)
{
ShowIndicator();
scanf("%s", command);
if(!strcmp(command, "exit"))
return 0;
else if(!strcmp(command, "halt"))
HaltSystem();
else if(!strcmp(command, "load"))
{
scanf("%s", filename);
if((load=LoadCode(filename)) == 0)
HandleError(-10004);
else if(load == -1)
ClearMemory();
else
printf("源文件%s已载入\n", filename);
}
else if(!strcmp(command, "run"))
if(load)
{
printf("正在运行源文件%s\n", filename);
puts("提示符?代表程序要求键盘输入");
puts("---------------------------------");
RunCode();
puts("---------------------------------");
}
else
HandleError(-10003);
else if(!strcmp(command, "view"))
if(load)
ViewCode(filename);
else
HandleError(-10003);
else if(!strcmp(command, "clear"))
system("cls");
else if(!strcmp(command, "help"))
ShowHelp();
else
puts("无效的指令");
}
return 0;
}

int InitSystem(void);
int ShowHelp(void);
int InitSystem(void);
int ShowIndicator(void);
int ClearMemory(void);
int LoadCode(char *);
int RunCode(void);
int ProcessLine(int code);
int HaltSystem(void);
int ViewCode(void);
int SMLRead(int);
int SMLWrite(int);
int SMLLoad(int);
int SMLStore(int);
int SMLAdd(int);
int SMLSubstract(int);
int SMLDivide(int);
int SMLMultiply(int);
int SMLBranch(int);
int SMLBranchNegative(int);
int SMLBranchZero(int);
int IsLegal(int codeline);
int HandleError(void);
本文出自 “波与粒的境界” 博客,谢绝转载!