全文预览

编译原理语法分析器实验报告

上传者:梦&殇 |  格式:doc  |  页数:6 |  大小:205KB

文档介绍
//总控程序privatevoidtotalControlProgram(){while(flag){stackPeek();//读取当前栈顶符号令X=栈顶符号if(XisVT()){if(X.equals(shuru1)){cur++;shuru1=curCharacter();stack.pop();System.out.printf("%-10d%-20s%-20s\n",(++count),stack.toString(),strToken.substring(cur,strToken.length()));}else{ERROR();}}elseif(X.equals("#")){if(X.equals(shuru1)){flag=false;}else{ERROR();}}elseif(productionType()){if(VNTI().equals("")){ERROR();}elseif(VNTI().equals("ε")){stack.pop();System.out.printf("%-10d%-20s%-20s%s->%s\n",(++count),stack.toString(),strToken.substring(cur,strToken.length()),X,VNTI());}else{pushStack();}}else{ERROR();}}}//出现错误privatevoidERROR(){System.out.println("输入串出现错误,无法进行分析");System.exit(0);}//打印存储分析表privatevoidprintf(){if(!flag){System.out.println("****分析成功啦!****");}else{System.out.println("****分析失败了****");}}}

收藏

分享

举报
下载此文档