?? cm_scan.cpp
字號:
strcpy(pgm, argv[1]) ;
if (strchr(pgm, '.') == NULL)
strcat(pgm, ".cm");
yyin = fopen(pgm,"r");
if (yyin == NULL)
{
fprintf(stderr,"File %s not found\n",pgm);
exit(1);
}
source = yyin;
listing = stdout; /* send listing to screen */
fprintf(listing,"\nC-Minus COMPILATION: %s\n", pgm);
#if NO_PARSE
while (getToken() != ENDFILE);
#else
syntaxTree = parse();
if (TraceParse)
{
fprintf(listing,"\nSyntax tree:\n");
printTree(syntaxTree);
}
#if !NO_ANALYZE
if (! Error)
{
if (TraceAnalyze)
fprintf(listing,"\nBuilding Symbol Table...\n");
buildSymtab(syntaxTree);
st_reset();
if (TraceAnalyze)
{
fprintf(listing,"\nSyntax tree:\n");
printTree(syntaxTree);
}
}
if(! Error)
{
if (TraceAnalyze)
fprintf(listing,"\nChecking Types...\n");
typeCheck(syntaxTree);
st_reset();
if (TraceAnalyze)
fprintf(listing,"\nType Checking Finished\n");
}
#if !NO_CODE
if (! Error)
{
char * codefile;
int fnlen = strcspn(pgm,".");
codefile = (char *) calloc(fnlen+4, sizeof(char));
strncpy(codefile,pgm,fnlen);
strcat(codefile,".p");
code = fopen(codefile,"w");
if (code == NULL)
{
printf("Unable to open %s\n",codefile);
exit(1);
}
codeGen(syntaxTree,codefile);
st_reset();
fclose(code);
}
#endif
#endif
#endif
fclose(source);
return 0;
}
int getToken()
{
static int firstTime = TRUE;
int currentToken;
if (firstTime)
{
firstTime = FALSE;
lineno++;
yyin = source;
yyout = listing;
}
currentToken = yylex();
if(currentToken == 0)
currentToken = ENDFILE;
strncpy(tokenString,yytext,MAXTOKENLEN);
if (TraceScan)
{
fprintf(listing,"\t%d: ",lineno);
printToken(currentToken,tokenString);
}
return currentToken;
}
int yywrap()
{
return 1;
}
#line 585 "E:\\Myworks\\Compiler\\C_Minus\\CM_scan.c"
YYCONST yymatch_t YYNEARFAR YYBASED_CODE YYDCDECL yymatch[] = {
0
};
int YYNEAR YYDCDECL yytransitionmax = 249;
YYCONST yytransition_t YYNEARFAR YYBASED_CODE YYDCDECL yytransition[] = {
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 33, 1 },
{ 32, 1 },
{ 33, 33 },
{ 0, 31 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 33, 1 },
{ 13, 1 },
{ 33, 33 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 27, 1 },
{ 31, 1 },
{ 20, 1 },
{ 21, 1 },
{ 16, 1 },
{ 14, 1 },
{ 19, 1 },
{ 15, 1 },
{ 52, 48 },
{ 17, 1 },
{ 30, 1 },
{ 29, 1 },
{ 29, 1 },
{ 29, 1 },
{ 29, 1 },
{ 29, 1 },
{ 29, 1 },
{ 29, 1 },
{ 29, 1 },
{ 29, 1 },
{ 49, 17 },
{ 18, 1 },
{ 11, 1 },
{ 10, 1 },
{ 12, 1 },
{ 45, 11 },
{ 46, 12 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 22, 1 },
{ 0, 15 },
{ 23, 1 },
{ 48, 15 },
{ 28, 1 },
{ 47, 13 },
{ 28, 1 },
{ 28, 1 },
{ 4, 1 },
{ 28, 1 },
{ 7, 1 },
{ 5, 1 },
{ 28, 1 },
{ 28, 1 },
{ 3, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 9, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 6, 1 },
{ 8, 1 },
{ 28, 1 },
{ 28, 1 },
{ 28, 1 },
{ 24, 1 },
{ 26, 1 },
{ 25, 1 },
{ 36, 3 },
{ 37, 4 },
{ 38, 5 },
{ 40, 6 },
{ 41, 7 },
{ 39, 5 },
{ 42, 8 },
{ 43, 9 },
{ 35, 3 },
{ 54, 35 },
{ 55, 37 },
{ 56, 38 },
{ 57, 39 },
{ 58, 40 },
{ 59, 41 },
{ 60, 42 },
{ 61, 43 },
{ 64, 55 },
{ 65, 56 },
{ 66, 58 },
{ 67, 59 },
{ 68, 60 },
{ 69, 61 },
{ 70, 65 },
{ 71, 68 },
{ 72, 69 },
{ 73, 72 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 50, 26 },
{ 44, 10 },
{ 63, 53 },
{ 51, 27 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 28, 73 },
{ 0, 0 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 28, 73 },
{ 29, 29 },
{ 29, 29 },
{ 29, 29 },
{ 29, 29 },
{ 29, 29 },
{ 29, 29 },
{ 29, 29 },
{ 29, 29 },
{ 29, 29 },
{ 29, 29 },
{ 62, 62 },
{ 62, 62 },
{ 62, 62 },
{ 62, 62 },
{ 62, 62 },
{ 62, 62 },
{ 62, 62 },
{ 62, 62 },
{ 62, 62 },
{ 62, 62 }
};
YYCONST yystate_t YYNEARFAR YYBASED_CODE YYDCDECL yystate[] = {
{ 0, 0, 0 },
{ -34, 1, 0 },
{ 1, 0, 0 },
{ 73, 25, 33 },
{ 73, 24, 33 },
{ 73, 21, 33 },
{ 73, 19, 33 },
{ 73, 23, 33 },
{ 73, 29, 33 },
{ 73, 33, 33 },
{ 13, 104, 14 },
{ 13, 3, 15 },
{ 13, 4, 16 },
{ 0, 36, 31 },
{ 0, 0, 17 },
{ 29, 47, 18 },
{ 0, 0, 19 },
{ 0, 17, 20 },
{ 0, 0, 21 },
{ 0, 0, 22 },
{ 0, 0, 23 },
{ 0, 0, 24 },
{ 0, 0, 25 },
{ 0, 0, 26 },
{ 0, 0, 27 },
{ 0, 0, 28 },
{ 0, 40, 39 },
{ 0, 129, 39 },
{ 73, 0, 33 },
{ 48, 181, 34 },
{ 48, 0, 34 },
{ -53, 3, 39 },
{ 0, 0, 37 },
{ 0, 3, 38 },
{ 0, 0, 39 },
{ 73, 20, 33 },
{ 73, 0, 5 },
{ 73, 40, 33 },
{ 73, 27, 33 },
{ 73, 25, 33 },
{ 73, 35, 33 },
{ 73, 26, 33 },
{ 73, 37, 33 },
{ 73, 27, 33 },
{ 0, 0, 10 },
{ 0, 0, 11 },
{ 0, 0, 12 },
{ 0, 0, 13 },
{ 0, 1, 0 },
{ 0, 0, 32 },
{ 0, 0, 29 },
{ 0, 0, 30 },
{ 62, 0, 0 },
{ 0, 127, 0 },
{ 73, 0, 1 },
{ 73, 30, 33 },
{ 73, 48, 33 },
{ 73, 0, 8 },
{ 73, 46, 33 },
{ 73, 46, 33 },
{ 73, 40, 33 },
{ 73, 32, 33 },
{ 15, 191, 35 },
{ 0, 0, 36 },
{ 73, 0, 2 },
{ 73, 34, 33 },
{ 73, 0, 4 },
{ 73, 0, 6 },
{ 73, 50, 33 },
{ 73, 38, 33 },
{ 73, 0, 3 },
{ 73, 0, 7 },
{ 73, 43, 33 },
{ 62, 106, 9 }
};
YYCONST yybackup_t YYNEARFAR YYBASED_CODE YYDCDECL yybackup[] = {
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -