编译原理词法分析器C源代码.txt资料文档下载

上传人:b****2 文档编号:14629090 上传时间:2022-10-23 格式:TXT 页数:9 大小:8.40KB
下载 相关 举报
编译原理词法分析器C源代码.txt资料文档下载_第1页
第1页 / 共9页
编译原理词法分析器C源代码.txt资料文档下载_第2页
第2页 / 共9页
编译原理词法分析器C源代码.txt资料文档下载_第3页
第3页 / 共9页
编译原理词法分析器C源代码.txt资料文档下载_第4页
第4页 / 共9页
编译原理词法分析器C源代码.txt资料文档下载_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

编译原理词法分析器C源代码.txt资料文档下载

《编译原理词法分析器C源代码.txt资料文档下载》由会员分享,可在线阅读,更多相关《编译原理词法分析器C源代码.txt资料文档下载(9页珍藏版)》请在冰豆网上搜索。

编译原理词法分析器C源代码.txt资料文档下载

);

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;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 教育学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1