编译原理词法分析器C源代码.txt资料文档下载
- 文档编号:14629090
- 上传时间:2022-10-23
- 格式:TXT
- 页数:9
- 大小:8.40KB
编译原理词法分析器C源代码.txt资料文档下载
《编译原理词法分析器C源代码.txt资料文档下载》由会员分享,可在线阅读,更多相关《编译原理词法分析器C源代码.txt资料文档下载(9页珍藏版)》请在冰豆网上搜索。
);
exit(0);
}
else
�ɹ����ĵ�in.txt\n"
if((out=fopen("
out.txt"
w"
���ܴ��ĵ�out.txt�������Ŀ¼
�ɹ����ĵ�out.txt\n"
cp=fgetc(in);
while(cp!
=EOF)
/*���ĵ�ո��Ʊ�������з�*/
while(cp=='
'
||cp=='
\t'
\n'
)
{
cp=fgetc(in);
}
/*cp���鸴λ*/
i=0;
/*���ּ��*/
if(cp>
='
0'
&
cp<
9'
word[i++]=cp;
while(cp>
{
word[i++]=cp;
cp=fgetc(in);
}
if(cp=='
+'
-'
*'
/'
>
'
<
!
;
:
'
{'
}'
['
]'
('
)'
word[i]='
\0'
fprintf(out,"
%c%c%s%c,%d%c\n"
"
word,'
28,'
else
while(cp!
cp!
{
word[i++]=cp;
cp=fgetc(in);
}
%s%c%s%c%s\n"
error:
"
���ǺϷ��ı�ʶ��"
continue;
/*�ַ������*/
if((cp>
a'
z'
)||(cp>
A'
Z'
)||cp=='
_'
while((cp>
/*���������ּ��*/
if(strcmp(word,"
main"
)==0)
fprintf(out,"
1,'
elseif(strcmp(word,"
void"
2,'
int"
3,'
float"
4,'
double"
5,'
char"
6,'
struct"
7,'
elseif(strcmp(word,"
const"
8,'
extern"
9,'
register"
10,'
static"
11,'
if"
12,'
else"
13,'
switch"
14,'
elseif(strcmp(word,"
case"
15,'
for"
16,'
do"
17,'
while"
18,'
goto"
19,'
continue"
20,'
break"
21,'
default"
22,'
sizeof"
23,'
return"
24,'
else
�Զ����ʶ��:
29,'
/*�Ŵ�����ֻ������ĸ�����֡��»
��߹��ɣ�*/
while(cp!
{
word[i++]=cp;
cp=fgetc(in);
}
word[i]='
/*�����*/
if(cp=='
word[i]='
fprintf(out,"
31,'
32,'
33,'
word[i++]=cp;
cp=fgetc(in);
if(cp=='
){word[--i]='
while(cp!
){cp=fgetc(in);
}cp=fgetc(in);
}
else
fprintf(out,"
34,'
word[i]='
39,'
27,'
36,'
35,'
38,'
37,'
40,'
/*���*/
41,'
42,'
43,'
44,'
45,'
46,'
47,'
48,'
49,'
/*����ʶ����ַ�*/
word[i++]=cp;
cp=fgetc(in);
word[i]='
fprintf(out,"
fclose(in);
fclose(out);
printf("
�ɹ���in.txt�ĵ��ڴ�����дʷ��������������������out.txt�ĵ���\n"
return0;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 编译 原理 词法 分析器 源代码
![提示](https://static.bdocx.com/images/bang_tan.gif)