-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
73 lines (51 loc) · 1.55 KB
/
Copy pathmain.cpp
File metadata and controls
73 lines (51 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "data.h"
FILE * fin;
Token lookahead;
//BiTree first;
//关键字表
char Keyword[20][10] = { "begin", "as", "sub", "end", "if", "then", "else", "call", "while",
"do", "integer", "float", "input", "output", "var" };
//bool运算符
char Boolop[2][5] = { "and", "or" };
int main()
{
char fileName[256]="/Users/mac/Desktop/Html/YYYYYUfa/YYYYYUfa/aaa.txt";
////printf("请输入源程序文件名(包括路径):");
//gets(fileName);
if ((fin=fopen(fileName, "r"))==NULL)
{
printf("打开源程序文件出错!\n");
return 0;
}
/*
// 以下是测试代码,检查是否能依次正确输出源文件中的所有单词
do
{
getToken();
if(lookahead.type==ID)
printf("%s\n",lookahead.p);
else if(lookahead.type==INTC)
printf("%d\n",lookahead.val);
else if(lookahead.type==LP)
printf("(\n");
else if(lookahead.type==RP)
printf(")\n");
else if(lookahead.type==PLUS)
printf("+\n");
else if(lookahead.type==MINUS)
printf("-\n");
else if(lookahead.type==MUL)
printf("*\n");
else if(lookahead.type==DIV)
printf("/\n");
else if(lookahead.type==ERR)
printf("err: %s\n",lookahead.p);
}while(lookahead.type!=END);
*/
getToken();
//BiTNode* t=express();
//judge();
expression(); //文法起始符号对应的识别函数, 语法分析程序的起始入口
cout<<"分析成功!"<<endl;
return 0;
}