编译原理 我没看懂 100分
来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/08/05 08:37:43
编译原理 我没看懂 100分
#include
#include
#include
#include
using namespace std;
char cbuffer;
char * key[21]={"and","begin","const","div","do","else","end","function","if",
"integer","not","or","procedure","program","read","real","then","type","var","while","write"};
char * border[8]={",",";",":",".","(",")","[","]"};
char * relation[14]={"+","-","*","/","=","","","=",":=","{","}","#"};
ifstream ifile;
int search( char searchchar[],int wordtype)
{
int i=0;
switch(wordtype)
{
case 1:{for(i=0;i
#include
#include
#include
#include
using namespace std;
char cbuffer;
char * key[21]={"and","begin","const","div","do","else","end","function","if",
"integer","not","or","procedure","program","read","real","then","type","var","while","write"};
char * border[8]={",",";",":",".","(",")","[","]"};
char * relation[14]={"+","-","*","/","=","","","=",":=","{","}","#"};
ifstream ifile;
int search( char searchchar[],int wordtype)
{
int i=0;
switch(wordtype)
{
case 1:{for(i=0;i
![编译原理 我没看懂 100分](/uploads/image/z/18990425-65-5.jpg?t=%E7%BC%96%E8%AF%91%E5%8E%9F%E7%90%86+%E6%88%91%E6%B2%A1%E7%9C%8B%E6%87%82+100%E5%88%86)
+739227481 你是要解释,还是要啥?
再问: 要求完善的那部分的解释 原理
再答: char otherprocess(char buffer) { //请完善该部分程序。 int atype; char other[4]; //缓存前2个字符外加一个\0,另外剩下一个字符边界哨兵牌 /*while((isalpha(buffer))||(isdigit(buffer))) { other[++i]=buffer; buffer=ifile.get(); } */ other[0]=buffer;//当前字符存入other[0] buffer=ifile.get();//下一个字符获取, other[1]=buffer;//存入other[1] other[2]='\0';//结束该次获取字符 if(search(other,3))//检测该次获取的字符串是否为第三类,也就是在relation数组里的关键字 { atype=search(other,3);//如果是,则返回该字符串的类型 cout
再问: 要求完善的那部分的解释 原理
再答: char otherprocess(char buffer) { //请完善该部分程序。 int atype; char other[4]; //缓存前2个字符外加一个\0,另外剩下一个字符边界哨兵牌 /*while((isalpha(buffer))||(isdigit(buffer))) { other[++i]=buffer; buffer=ifile.get(); } */ other[0]=buffer;//当前字符存入other[0] buffer=ifile.get();//下一个字符获取, other[1]=buffer;//存入other[1] other[2]='\0';//结束该次获取字符 if(search(other,3))//检测该次获取的字符串是否为第三类,也就是在relation数组里的关键字 { atype=search(other,3);//如果是,则返回该字符串的类型 cout