当前位置:文档之家› C语言词法分析器实验报告

C语言词法分析器实验报告

计算机科学与工程系
编译原理课程设计实验报告姓名:__ ******__ 学号_ *******__ 年级专业及班级___08计算机科学与技术成绩
扫描引号:
扫描单词:
扫描其他字符:
实验环境:需要TC、VC++ 6.0等开发工具作为本次试验的环境。

fprintf(fp1,"*********************************************************\n");
}
int guanjz(char ch1[])//关键字和标识符判断
{
char ch2[32][9]={"auto","double","int","struct","break","else","long","switch","case","enum", "register","typedef","char","extern","return","union","const","float","short",
"unsigned","continue","for","signed","void","default","goto","sizeof",
"volatile","do","while","static","if"};//定义关键字集
for(int i=0;i<32;i++)
{//逐个比对如果为关键字则返回类别i+1
if(!strcmp(ch1,ch2[i]))return i+1;
}
return 47;//否则返回一般标识符类
}
总结:
指导教师签名:
2011年4月12日星期二。

相关主题