📄 main.cpp
字号:
#include "globals.h"
#include "util.h"
#include "scan.h"
#include "parseLL_1.h"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
FILE* source; /* source code text file */
FILE* scan;
FILE* parse;
FILE* stree;
int lineno=0; /* source line number for listing */
/* allocate and set tracing flags */
int EchoSource = TRUE;
int TraceScan = TRUE;
int Error = FALSE;
int ParseError=false;
// tokenno=0;
int main( int argc, char * argv[] )
{
char pgm[120]; /* source code file name */
// char pgmscan[120];
// char pgmparse[120];
if (argc != 2)
{ //fprintf(stderr,"usage: %s <filename>\n",argv[0]);
printf("Input your txt:\n");
scanf("%s",pgm);
//exit(1);
}
else{ strcpy(pgm,argv[1]) ;}
if (strchr (pgm, '.') == NULL)
strcat(pgm,".txt");
source = fopen(pgm,"r");
scan=fopen("scan.txt","w");
parse=fopen("parse.txt","w");
stree=fopen("stree.txt","w");
if (source==NULL)
{
fprintf(stderr,"File %s not found\n",pgm);
exit(1);
}
parseTree a;
a=new StreeNode;
MainCtrl(a);
printTree(a);
// printfCreatM();
while (getToken()!=ENDFILE)
{
};
getchar();
if(Error==TRUE)
printf("C_MINUS SCAN ERROR:%s\n",pgm);
else
printf("\nC_MINUS SCAN COMPILATION: %s\n",pgm);
if(ParseError==TRUE)
printf("C_MINUS PARSE ERROR:%s\n",pgm);
else
printf("\nC_MINUS PARSE COMPILATION: %s\n",pgm);
getchar();
fclose(source);
fclose(scan);
fclose(stree);
fclose(parse);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -