编译原理实验报告 词法分析(4)
发布时间:2021-06-06
发布时间:2021-06-06
ch=prog[p++]; } p--; syn=3; }
else if(ch==';' ||ch=='('||ch==')') syn=5;
else if(ch=='#') syn=0; return 0; }
int main() {p=0;
cout<<"\t\t\t\t 词法分析\n请输入源程序: \n"; do {cin>>ch;
prog[p++]=ch; }while(ch!='#'); q=p; p=0; do { scaner(); switch(syn) { case 3: cout<<"(3,"<<sum<<")\n";break; case -1: cout<<"error!"; break; case 4: cout<<"(4,"<<ch<<")"<<endl;break; case 5:cout<<"(5,"<<ch<<")\n";break; case 0:cout<<"(0,#)"<<endl;break;
default: cout<<"("<<syn<<","<<token<<")\n"; }
}while (syn!=0); return 0; }
上一篇:魔法城堡主持词
下一篇:浅析苏宁发展现状及营销策略