语法分析程序报告.docx
《语法分析程序报告.docx》由会员分享,可在线阅读,更多相关《语法分析程序报告.docx(38页珍藏版)》请在冰豆网上搜索。
语法分析程序报告
基本语法分析程序报告
姓名:
牛添识
班级:
软件94
学号:
09161072
1.程序设计语言文法的形式化描述
pascal语言子集文法
<赋值语句>-><左部>:
=<右部>
<左部>-><标识符>
<右部>-><算术表达式>
<条件语句>->if<标识符>then<语句>||if<标识符>then<语句>else<语句>
<算数表达式>-><项>||<算数表达式><加运算符><项>
<项>-><因子>||<项><乘运算符><因子>
<因子>-><标识符>||<无符号整数>||true||false
2.单词种别定义
(1)保留字
Program
(1),begin
(2),end(3),var(4),interger(5),if(6),then(7)
else(8),do(9),while(10)
(2)标识符(11)
(3)整形常数(12)
(4)界符,运算符
+(13)-(14),((15),)(16),=(17),>(18),<(19)
;(20)(分号,语句结束时使用),(21)(定义变量时分隔多个变量)
:
(22)(冒号,定义变量时使用):
=(23)(冒号+等号,赋值号)
*(24)乘,/(25)除
3.语法分析程序
#include
#include"fstream.h"
classQueue
{
private:
charptr[128];
inthead;
inttail;
public:
voidcopy(Queue*queue)
queue->head=head;
queue->tail=tail;
for(inti=head;i{queue->ptr[i]=ptr[i];}}boolFind(intt){for(inti=head;i{if(ptr[i]==t)returntrue;}returnfalse;}Queue(){head=tail=0;}voidpushQueue(intpara){ptr[tail]=para;tail++;}intpopQueue(){inttemp=ptr[head];head++;returntemp;}voidclear(){head=tail=0;}boolisEmpty(){if(tail-head>0){returnfalse;}returntrue;}};classPro_Process{private:intsta_stack;public:Pro_Process(){sta_stack=0;}public:voidProcess(char*ptr){char*temp2=ptr;while((int)*temp2!=0)//去掉//和/*{if(sta_stack!=0)//进入夹逼注释阶段{//寻找下一个标记符号if((int)*temp2=='*'&&(int)*(temp2+1)=='/')//寻找到{sta_stack--;*temp2=32;*(temp2+1)=32;}if((int)*temp2=='/'&&(int)*(temp2+1)=='*'){sta_stack++;*temp2=32;*(temp2+1)=32;}else//否则在注释中置为空格{*temp2=32;}}else//正常进行阶段{if((int)*temp2=='/'){if((int)*(temp2+1)=='/'){Pro_process1(temp2);return;}if((int)*(temp2+1)=='*'){*temp2=32;sta_stack++;}}}temp2++;}}private:/*将当前符号置为0**/voidPro_process1(char*temp2){*temp2=0;}};classTwo_pass{private:charptr[20];intindex;intstate;//确定返回的是否带有字符串,如果有为1;没有为0;public:boolequal(char*p){inttemp=strcmp(ptr,p);if(temp==0)//strcmp字符串匹配成功为0returntrue;returnfalse;}boolequal(intpara){if(para==index){returntrue;}returnfalse;}public:Two_pass(){index=0;}voidTwo_copy(char*p,intdex){state=1;intcount=0;while(*p!='\0'){ptr[count]=*p;count++;p++;}ptr[count]='\0';index=dex;}voidTwo_copy(intdex)//返回值没有字符串{index=dex;state=0;if(1==index)strcpy(ptr,"program");if(2==index)strcpy(ptr,"begin");if(3==index)strcpy(ptr,"end");if(4==index)strcpy(ptr,"var");if(5==index)strcpy(ptr,"integer");if(6==index)strcpy(ptr,"if");if(7==index)strcpy(ptr,"then");if(8==index)strcpy(ptr,"else");if(9==index)strcpy(ptr,"do");if(10==index)strcpy(ptr,"while");if(13==index)strcpy(ptr,"+");if(14==index)strcpy(ptr,"-");if(15==index)strcpy(ptr,"(");if(16==index)strcpy(ptr,")");if(17==index)strcpy(ptr,"=");if(18==index)strcpy(ptr,">");if(19==index)strcpy(ptr,"<");if(20==index)strcpy(ptr,";");if(21==index)strcpy(ptr,",");if(22==index)strcpy(ptr,":");if(23==index)strcpy(ptr,":=");if(24==index)strcpy(ptr,"*");if(25==index)strcpy(ptr,"/");}voidTwo_copy(Two_passps){Two_copy(ps.get_String(),ps.getIndex());}char*get_String(){char*p=ptr;returnp;}intgetIndex(){returnindex;}intgetState(){returnstate;}};classAccidenceAnalyse{private:ifstreamifs;private:Pro_Processpro;charch;charstrInstream[257];//存储文件的行,最后一位为回车charstrToken[257];//新生成的单词intcount;//标记strToken[]数组下一个方位char*p;//标记strInstream[]数组方位private:intline;public:AccidenceAnalyse(){ch=32;p=NULL;count=0;ifs.open("test.txt",ios::in);//init_map();line=0;}public:intgetLine(){returnline;}private:voidGetchar()//取当前字符,指针向下移位{ch=*p;p++;}voidgetNBC(){while(ch==32){Getchar();}}voidConcat(){strToken[count]=ch;count++;}voidAppend(){strToken[count]='\0';}boolisLetter(){if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))returntrue;returnfalse;}boolisDigit(){if(ch>='0'&&ch<='9')returntrue;returnfalse;}voidRetract(){ch=32;p--;}public:intreserve(){switch(strToken[0]){case'p':{if(strcmp(strToken,"program")==0){return1;}return0;}break;case'b':{if(strcmp(strToken,"begin")==0){return2;}return0;}break;case'e':{if(strcmp(strToken,"end")==0){return3;}if(strcmp(strToken,"else")==0){return8;}return0;}break;case'v':{if(strcmp(strToken,"var")==0){return4;}return0;}break;case'i':{if(strcmp(strToken,"integer")==0){return5;}if(strcmp(strToken,"if")==0){return6;}return0;}break;case't':{if(strcmp(strToken,"then")==0){return7;}return0;}break;case'd':{if(strcmp(strToken,"do")==0){return9;}return0;}break;case'w':{if(strcmp(strToken,"while")==0){return10;}return0;}break;default:{return0;}}}public:boolProcess(Two_pass*pass)//处理程序返回二值对{if(ifs.eof()!=0){returnfalse;}if(p==NULL||(int)ch==0)//第一次初始化,或者指针为末尾,引进新的行{line++;ifs.getline(strInstream,sizeof(strInstream),'\n');p=strInstream;//指针指到首位pro.Process(strInstream);Getchar();}getNBC();//////////////跨行注释代码if((int)ch==0){line++;ifs.getline(strInstream,sizeof(strInstream),'\n');p=strInstream;//指针指到首位pro.Process(strInstream);Getchar();}getNBC();//////////////count=0;//每一次取值的时候新的单词放到缓冲数组的第一位intcode;if(isLetter()){while(isLetter()||isDigit()){Concat();Getchar();Append();}code=reserve();if(code==0)//为一般的标识符{pass->Two_copy(strToken,11);returntrue;}else{pass->Two_copy(code);returntrue;}}else{if(isDigit()){while(isDigit()){Concat();Getchar();}Append();pass->Two_copy(strToken,12);returntrue;}else{if(ch=='+'){pass->Two_copy(13);Getchar();returntrue;}if(ch=='-'){pass->Two_copy(14);Getchar();returntrue;}if(ch=='('){pass->Two_copy(15);Getchar();returntrue;}if(ch=='*'){pass->Two_copy(24);Getchar();returntrue;}if(ch=='/'){pass->Two_copy(25);Getchar();returntrue;}if(ch==')'){pass->Two_copy(16);Getchar();returntrue;}if(ch=='='){pass->Two_copy(17);Getchar();returntrue;}if(ch=='>'){pass->Two_copy(18);Getchar();returntrue;}if(ch=='<'){pass->Two_copy(19);Getchar();returntrue;}if(ch==';'){pass->Two_copy(20);Getchar();returntrue;}if(ch==','){pass->Two_copy(21);Getchar();returntrue;}if(ch==':'){Getchar();if(ch=='='){pass->Two_copy(23);Getchar();returntrue;}else{pass->Two_copy(22);returntrue;}}} }//returnfalse;}};classAnalyseMachine{private:Two_passSYM;AccidenceAnalysesss;boolsysmbol;private:QueueErrorqueue;//错误队列QueueRightqueue;//正确队列public:AnalyseMachine(){sysmbol=true;}public:boolgetCorretMess(){returnsysmbol;}private:boolADVANCE(){returnsss.Process(&SYM);}public:voidtest(){inti=0;while(ADVANCE()){i++;}}private:boolgetNextLine()//取到本行分号;返回true,如果文件尾返回false{if(SYM.equal(20)){returntrue;}else{while(sss.Process(&SYM)){if(SYM.equal(20)){returntrue;}}returnfalse;//文件尾}}public:boolZ()//如果有句子,继续分析,返回true,否则为文件尾,返回false{sysmbol=true;Errorqueue.clear();//错误消息队列清空Rightqueue.clear();//正确队列清空if(false==ADVANCE()){returnfalse;}if(SYM.equal(6))//if语句{Rightqueue.pushQueue(10);A();getNextLine();}else{if(SYM.equal(11))//赋值语句{I();getNextLine();}else{if(SYM.equal(10))//循环语句{Rightqueue.pushQueue(2);L();getNextLine();}else{ERROR();}}}if(sysmbol==false)cout<<"false";elsecout<<"true";returntrue;}private:///////////////////赋值语句voidI(){Rightqueue.pushQueue(3);if(SYM.equal(11))//标识符{J();if(SYM.equal(23))//赋值号ADVANCE();else{ERROR();return;}D();//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*if(SYM.equal(20)){}else{ERROR();}*/
queue->ptr[i]=ptr[i];
}
boolFind(intt)
for(inti=head;i{if(ptr[i]==t)returntrue;}returnfalse;}Queue(){head=tail=0;}voidpushQueue(intpara){ptr[tail]=para;tail++;}intpopQueue(){inttemp=ptr[head];head++;returntemp;}voidclear(){head=tail=0;}boolisEmpty(){if(tail-head>0){returnfalse;}returntrue;}};classPro_Process{private:intsta_stack;public:Pro_Process(){sta_stack=0;}public:voidProcess(char*ptr){char*temp2=ptr;while((int)*temp2!=0)//去掉//和/*{if(sta_stack!=0)//进入夹逼注释阶段{//寻找下一个标记符号if((int)*temp2=='*'&&(int)*(temp2+1)=='/')//寻找到{sta_stack--;*temp2=32;*(temp2+1)=32;}if((int)*temp2=='/'&&(int)*(temp2+1)=='*'){sta_stack++;*temp2=32;*(temp2+1)=32;}else//否则在注释中置为空格{*temp2=32;}}else//正常进行阶段{if((int)*temp2=='/'){if((int)*(temp2+1)=='/'){Pro_process1(temp2);return;}if((int)*(temp2+1)=='*'){*temp2=32;sta_stack++;}}}temp2++;}}private:/*将当前符号置为0**/voidPro_process1(char*temp2){*temp2=0;}};classTwo_pass{private:charptr[20];intindex;intstate;//确定返回的是否带有字符串,如果有为1;没有为0;public:boolequal(char*p){inttemp=strcmp(ptr,p);if(temp==0)//strcmp字符串匹配成功为0returntrue;returnfalse;}boolequal(intpara){if(para==index){returntrue;}returnfalse;}public:Two_pass(){index=0;}voidTwo_copy(char*p,intdex){state=1;intcount=0;while(*p!='\0'){ptr[count]=*p;count++;p++;}ptr[count]='\0';index=dex;}voidTwo_copy(intdex)//返回值没有字符串{index=dex;state=0;if(1==index)strcpy(ptr,"program");if(2==index)strcpy(ptr,"begin");if(3==index)strcpy(ptr,"end");if(4==index)strcpy(ptr,"var");if(5==index)strcpy(ptr,"integer");if(6==index)strcpy(ptr,"if");if(7==index)strcpy(ptr,"then");if(8==index)strcpy(ptr,"else");if(9==index)strcpy(ptr,"do");if(10==index)strcpy(ptr,"while");if(13==index)strcpy(ptr,"+");if(14==index)strcpy(ptr,"-");if(15==index)strcpy(ptr,"(");if(16==index)strcpy(ptr,")");if(17==index)strcpy(ptr,"=");if(18==index)strcpy(ptr,">");if(19==index)strcpy(ptr,"<");if(20==index)strcpy(ptr,";");if(21==index)strcpy(ptr,",");if(22==index)strcpy(ptr,":");if(23==index)strcpy(ptr,":=");if(24==index)strcpy(ptr,"*");if(25==index)strcpy(ptr,"/");}voidTwo_copy(Two_passps){Two_copy(ps.get_String(),ps.getIndex());}char*get_String(){char*p=ptr;returnp;}intgetIndex(){returnindex;}intgetState(){returnstate;}};classAccidenceAnalyse{private:ifstreamifs;private:Pro_Processpro;charch;charstrInstream[257];//存储文件的行,最后一位为回车charstrToken[257];//新生成的单词intcount;//标记strToken[]数组下一个方位char*p;//标记strInstream[]数组方位private:intline;public:AccidenceAnalyse(){ch=32;p=NULL;count=0;ifs.open("test.txt",ios::in);//init_map();line=0;}public:intgetLine(){returnline;}private:voidGetchar()//取当前字符,指针向下移位{ch=*p;p++;}voidgetNBC(){while(ch==32){Getchar();}}voidConcat(){strToken[count]=ch;count++;}voidAppend(){strToken[count]='\0';}boolisLetter(){if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))returntrue;returnfalse;}boolisDigit(){if(ch>='0'&&ch<='9')returntrue;returnfalse;}voidRetract(){ch=32;p--;}public:intreserve(){switch(strToken[0]){case'p':{if(strcmp(strToken,"program")==0){return1;}return0;}break;case'b':{if(strcmp(strToken,"begin")==0){return2;}return0;}break;case'e':{if(strcmp(strToken,"end")==0){return3;}if(strcmp(strToken,"else")==0){return8;}return0;}break;case'v':{if(strcmp(strToken,"var")==0){return4;}return0;}break;case'i':{if(strcmp(strToken,"integer")==0){return5;}if(strcmp(strToken,"if")==0){return6;}return0;}break;case't':{if(strcmp(strToken,"then")==0){return7;}return0;}break;case'd':{if(strcmp(strToken,"do")==0){return9;}return0;}break;case'w':{if(strcmp(strToken,"while")==0){return10;}return0;}break;default:{return0;}}}public:boolProcess(Two_pass*pass)//处理程序返回二值对{if(ifs.eof()!=0){returnfalse;}if(p==NULL||(int)ch==0)//第一次初始化,或者指针为末尾,引进新的行{line++;ifs.getline(strInstream,sizeof(strInstream),'\n');p=strInstream;//指针指到首位pro.Process(strInstream);Getchar();}getNBC();//////////////跨行注释代码if((int)ch==0){line++;ifs.getline(strInstream,sizeof(strInstream),'\n');p=strInstream;//指针指到首位pro.Process(strInstream);Getchar();}getNBC();//////////////count=0;//每一次取值的时候新的单词放到缓冲数组的第一位intcode;if(isLetter()){while(isLetter()||isDigit()){Concat();Getchar();Append();}code=reserve();if(code==0)//为一般的标识符{pass->Two_copy(strToken,11);returntrue;}else{pass->Two_copy(code);returntrue;}}else{if(isDigit()){while(isDigit()){Concat();Getchar();}Append();pass->Two_copy(strToken,12);returntrue;}else{if(ch=='+'){pass->Two_copy(13);Getchar();returntrue;}if(ch=='-'){pass->Two_copy(14);Getchar();returntrue;}if(ch=='('){pass->Two_copy(15);Getchar();returntrue;}if(ch=='*'){pass->Two_copy(24);Getchar();returntrue;}if(ch=='/'){pass->Two_copy(25);Getchar();returntrue;}if(ch==')'){pass->Two_copy(16);Getchar();returntrue;}if(ch=='='){pass->Two_copy(17);Getchar();returntrue;}if(ch=='>'){pass->Two_copy(18);Getchar();returntrue;}if(ch=='<'){pass->Two_copy(19);Getchar();returntrue;}if(ch==';'){pass->Two_copy(20);Getchar();returntrue;}if(ch==','){pass->Two_copy(21);Getchar();returntrue;}if(ch==':'){Getchar();if(ch=='='){pass->Two_copy(23);Getchar();returntrue;}else{pass->Two_copy(22);returntrue;}}} }//returnfalse;}};classAnalyseMachine{private:Two_passSYM;AccidenceAnalysesss;boolsysmbol;private:QueueErrorqueue;//错误队列QueueRightqueue;//正确队列public:AnalyseMachine(){sysmbol=true;}public:boolgetCorretMess(){returnsysmbol;}private:boolADVANCE(){returnsss.Process(&SYM);}public:voidtest(){inti=0;while(ADVANCE()){i++;}}private:boolgetNextLine()//取到本行分号;返回true,如果文件尾返回false{if(SYM.equal(20)){returntrue;}else{while(sss.Process(&SYM)){if(SYM.equal(20)){returntrue;}}returnfalse;//文件尾}}public:boolZ()//如果有句子,继续分析,返回true,否则为文件尾,返回false{sysmbol=true;Errorqueue.clear();//错误消息队列清空Rightqueue.clear();//正确队列清空if(false==ADVANCE()){returnfalse;}if(SYM.equal(6))//if语句{Rightqueue.pushQueue(10);A();getNextLine();}else{if(SYM.equal(11))//赋值语句{I();getNextLine();}else{if(SYM.equal(10))//循环语句{Rightqueue.pushQueue(2);L();getNextLine();}else{ERROR();}}}if(sysmbol==false)cout<<"false";elsecout<<"true";returntrue;}private:///////////////////赋值语句voidI(){Rightqueue.pushQueue(3);if(SYM.equal(11))//标识符{J();if(SYM.equal(23))//赋值号ADVANCE();else{ERROR();return;}D();//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*if(SYM.equal(20)){}else{ERROR();}*/
if(ptr[i]==t)
returntrue;
returnfalse;
Queue()
head=tail=0;
voidpushQueue(intpara)
ptr[tail]=para;
tail++;
intpopQueue()
inttemp=ptr[head];
head++;
returntemp;
voidclear()
boolisEmpty()
if(tail-head>0)
};
classPro_Process
intsta_stack;
Pro_Process()
sta_stack=0;
voidProcess(char*ptr)
char*temp2=ptr;
while((int)*temp2!
=0)//去掉//和/*
if(sta_stack!
=0)//进入夹逼注释阶段
//寻找下一个标记符号
if((int)*temp2=='*'&&(int)*(temp2+1)=='/')//寻找到
sta_stack--;
*temp2=32;
*(temp2+1)=32;
if((int)*temp2=='/'&&(int)*(temp2+1)=='*')
sta_stack++;
else//否则在注释中置为空格
else//正常进行阶段
if((int)*temp2=='/')
if((int)*(temp2+1)=='/')
Pro_process1(temp2);
return;
if((int)*(temp2+1)=='*')
temp2++;
/*将当前符号置为0
*
*/
voidPro_process1(char*temp2)
*temp2=0;
classTwo_pass
charptr[20];
intindex;
intstate;//确定返回的是否带有字符串,如果有为1;没有为0;
boolequal(char*p)
inttemp=strcmp(ptr,p);
if(temp==0)//strcmp字符串匹配成功为0
boolequal(intpara)
if(para==index)
Two_pass()
index=0;
voidTwo_copy(char*p,intdex)
state=1;
intcount=0;
while(*p!
='\0')
ptr[count]=*p;
count++;
p++;
ptr[count]='\0';
index=dex;
voidTwo_copy(intdex)//返回值没有字符串
state=0;
if(1==index)
strcpy(ptr,"program");
if(2==index)
strcpy(ptr,"begin");
if(3==index)
strcpy(ptr,"end");
if(4==index)
strcpy(ptr,"var");
if(5==index)
strcpy(ptr,"integer");
if(6==index)
strcpy(ptr,"if");
if(7==index)
strcpy(ptr,"then");
if(8==index)
strcpy(ptr,"else");
if(9==index)
strcpy(ptr,"do");
if(10==index)
strcpy(ptr,"while");
if(13==index)
strcpy(ptr,"+");
if(14==index)
strcpy(ptr,"-");
if(15==index)
strcpy(ptr,"(");
if(16==index)
strcpy(ptr,")");
if(17==index)
strcpy(ptr,"=");
if(18==index)
strcpy(ptr,">");
if(19==index)
strcpy(ptr,"<");
if(20==index)
strcpy(ptr,";");
if(21==index)
strcpy(ptr,",");
if(22==index)
strcpy(ptr,":
");
if(23==index)
=");
if(24==index)
strcpy(ptr,"*");
if(25==index)
strcpy(ptr,"/");
voidTwo_copy(Two_passps)
Two_copy(ps.get_String(),ps.getIndex());
char*get_String()
char*p=ptr;
returnp;
intgetIndex()
returnindex;
intgetState()
returnstate;
classAccidenceAnalyse
ifstreamifs;
Pro_Processpro;
charch;
charstrInstream[257];//存储文件的行,最后一位为回车
charstrToken[257];//新生成的单词
intcount;//标记strToken[]数组下一个方位
char*p;//标记strInstream[]数组方位
intline;
AccidenceAnalyse()
ch=32;
p=NULL;
count=0;
ifs.open("test.txt",ios:
:
in);
//init_map();
line=0;
intgetLine()
returnline;
voidGetchar()//取当前字符,指针向下移位
ch=*p;
voidgetNBC()
while(ch==32)
Getchar();
voidConcat()
strToken[count]=ch;
voidAppend()
strToken[count]='\0';
boolisLetter()
if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
boolisDigit()
if(ch>='0'&&ch<='9')
voidRetract()
p--;
intreserve()
switch(strToken[0])
case'p':
if(strcmp(strToken,"program")==0)
return1;
return0;
break;
case'b':
if(strcmp(strToken,"begin")==0)
return2;
case'e':
if(strcmp(strToken,"end")==0)
return3;
if(strcmp(strToken,"else")==0)
return8;
case'v':
if(strcmp(strToken,"var")==0)
return4;
case'i':
if(strcmp(strToken,"integer")==0)
return5;
if(strcmp(strToken,"if")==0)
return6;
case't':
if(strcmp(strToken,"then")==0)
return7;
case'd':
if(strcmp(strToken,"do")==0)
return9;
case'w':
if(strcmp(strToken,"while")==0)
return10;
default:
boolProcess(Two_pass*pass)//处理程序返回二值对
if(ifs.eof()!
=0)
if(p==NULL||(int)ch==0)//第一次初始化,或者指针为末尾,引进新的行
line++;
ifs.getline(strInstream,sizeof(strInstream),'\n');
p=strInstream;//指针指到首位
pro.Process(strInstream);
getNBC();
//////////////跨行注释代码
if((int)ch==0)
//////////////
count=0;//每一次取值的时候新的单词放到缓冲数组的第一位
intcode;
if(isLetter())
while(isLetter()||isDigit())
Concat();
Append();
code=reserve();
if(code==0)//为一般的标识符
pass->Two_copy(strToken,11);
else
pass->Two_copy(code);
if(isDigit())
while(isDigit())
pass->Two_copy(strToken,12);
if(ch=='+')
pass->Two_copy(13);
if(ch=='-')
pass->Two_copy(14);
if(ch=='(')
pass->Two_copy(15);
if(ch=='*')
pass->Two_copy(24);
if(ch=='/')
pass->Two_copy(25);
if(ch==')')
pass->Two_copy(16);
if(ch=='=')
pass->Two_copy(17);
if(ch=='>')
pass->Two_copy(18);
if(ch=='<')
pass->Two_copy(19);
if(ch==';')
pass->Two_copy(20);
if(ch==',')
pass->Two_copy(21);
if(ch==':
')
pass->Two_copy(23);
pass->Two_copy(22);
//returnfalse;
classAnalyseMachine
Two_passSYM;
AccidenceAnalysesss;
boolsysmbol;
QueueErrorqueue;//错误队列
QueueRightqueue;//正确队列
AnalyseMachine()
sysmbol=true;
boolgetCorretMess()
returnsysmbol;
boolADVANCE()
returnsss.Process(&SYM);
voidtest()
inti=0;
while(ADVANCE())
i++;
boolgetNextLine()//取到本行分号;返回true,如果文件尾返回false
if(SYM.equal(20))
while(sss.Process(&SYM))
returnfalse;//文件尾
boolZ()//如果有句子,继续分析,返回true,否则为文件尾,返回false
Errorqueue.clear();//错误消息队列清空
Rightqueue.clear();//正确队列清空
if(false==ADVANCE())
if(SYM.equal(6))//if语句
Rightqueue.pushQueue(10);
A();
getNextLine();
if(SYM.equal(11))//赋值语句
I();
if(SYM.equal(10))//循环语句
Rightqueue.pushQueue
(2);
L();
ERROR();
if(sysmbol==false)
cout<<"false";
cout<<"true";
///////////////////赋值语句
voidI()
Rightqueue.pushQueue(3);
if(SYM.equal(11))//标识符
J();
if(SYM.equal(23))//赋值号
ADVANCE();
D();/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*if(SYM.equal(20))
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1