编译原理 我没看懂 100分
编译原理 我没看懂 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
+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