编译原理词法分析程序不要C语言的,是C++版的,
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/20 14:59:00
编译原理词法分析程序不要C语言的,是C++版的,编译原理词法分析程序不要C语言的,是C++版的,编译原理词法分析程序不要C语言的,是C++版的,#include#include#include#inc
编译原理词法分析程序不要C语言的,是C++版的,
编译原理词法分析程序
不要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