作业帮 > 综合 > 作业

编译原理 我没看懂 100分

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/19 09:05:36
编译原理 我没看懂 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
编译原理 我没看懂 100分
+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