作业帮 > 综合 > 作业

编译原理词法分析程序不要C语言的,是C++版的,

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/11 09:57:51
编译原理词法分析程序
不要C语言的,是C++版的,
编译原理词法分析程序不要C语言的,是C++版的,
#include
#include
#include
#include
#include
using namespace std;
ifstream fp("source.txt",ios::in);
char cbuffer;
char *key[13]={"if","else","for","while","do","return","break","continue","int","void"
,"main","const","printf"}; //关键字
char *border[7]={ "," ,";" ,"{" ,"}" ,"(" ,")" ,"//"}; //分界符
char *arithmetic[6]={"+" ,"-" ,"*" ,"/" ,"++" ,"--"}; //运算符
char *relation[7]={"=" ,"==" ,"!="}; //关系运算符
char *lableconst[80]; //标识符
int constnum=40;
int lableconstnum=0;
int linenum=1; //统计常数和标识符数量
int search(char searchchar[],int wordtype)
{
int i=0,t=0;
switch (wordtype)
{
case 1:
{ for (i=0;i