编译课程设计报告书内容摘要:
的目的是为了便于对语法分析结果进行验证。 (1)文法 设算符优先文法 G 为: TTEE | FFTT | PFPF | iEP |)( 说明: i 为整型常数或者为标识符表示整型变量;使用中↑用 **表示。 (2)优先关系表 设优先关系表如表 12 所示。 表 12 优先关系表 + * ↑ i ( ) + * ↑ i ( ) 9 二、设计(实验)正文 1. 算符优先分析流程图 Y N N Y N Y includeiostream includestring using namespace std。 const int MAX=100。 char cost[8][8]={39。 39。 ,39。 +39。 ,39。 *39。 ,39。 !39。 ,39。 i39。 ,39。 (39。 ,39。 )39。 ,39。 39。 , 39。 +39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 , 39。 *39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 , 39。 !39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 , 开始 输出优先关系表 输入字符串 ‘ ’压栈 当前字符为‘ ’。 ’ 栈中为“ N” 不是句子 出栈 是句子 结束 栈顶终结符与当前字符比较 大于。 规约 下一个字符 入栈 10 39。 i39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 , 39。 (39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 =39。 ,39。 39。 , 39。 )39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 , 39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 39。 ,39。 =39。 }。 //the priority realiton graph class stack { int top。 char array[MAX]。 public: stack(){top=0。 } char GetTop() { return array[top1]。 } int Getsize() { return top。 } void PushStack(char c) { if(topMAX) array[top++]=c。 else coutover flow!endl。 } char *PopStack(int length) { if(top=length) { char *temp=new char[MAX]。 for(int i=0。 ilength。 i++) { temp[i]=array[toplength+i]。 } top=toplength。 temp[length]=39。 \039。 return temp。 } else { return NULL。 } 11 } char GetChar(int pos) { if((pos=0)amp。 amp。 (posMAX)) return array[pos]。 else return 39。 \039。 } void DispStack() { for(int i=0。 itop。 i++) { if (GetChar(i)==39。 !39。 ) { cout**。 cout39。 \b39。 } else coutGetChar(i)。 } if (thistop=8)cout39。 \t39。 else cout39。 \t39。 39。 \t39。 } }。 void DispCost() { for(int i=0。 i8。 i++) { for(int j=0。 j8。 j++) { if(cost[i][j]==39。 !39。 ) cout**39。 \t39。 else coutcost[i][j]39。 \t39。 } coutendl。 } } bool IsVT(char c) { bool flag=false。 for(int i=0。 i8。 i++) { 12 if(c==cost[0][i]) { flag=true。 } } if (((c=39。 a39。 )amp。 amp。 (c=39。 z39。 )) || ((c=39。 039。 )amp。 amp。 (c=39。 939。 ))) flag=true。 return flag。 } bool Num_Char(char c) { if (((c=39。 a39。 )amp。 amp。 (c=39。 z39。 )) || ((c=39。 039。 )amp。 amp。 (c=39。 939。 ))) return true。 else return false。 } int SearchCost(char ch1,char ch2)//set the realiton according to the cost { //0==equal , 1==above, 1==low, 2==NULL int i,j。 if(Num_Char(ch1)) ch1=39。 i39。 if(Num_Char(ch2)) ch2=39。 i39。 switch(ch1) { case 39。 +39。 :i=1。 break。 case 39。 *39。 :i=2。 break。 case 39。 !39。 :i=3。 break。 case 39。 i39。 :i=4。 break。 case 39。 (39。 :i=5。 break。 case 39。 )39。 :i=6。 break。 case 39。 39。 :i=7。 break。 } switch(ch2) { case 39。 +39。 :j=1。 break。 case 39。 *39。 :j=2。 break。 case 39。 !39。 :j=3。 break。 case 39。 i39。 :j=4。 break。 case 39。 (39。 :j=5。 break。 case 39。 )39。 :j=6。 break。 case 39。 39。 :j=7。 break。 } switch(cost[i][j]) 13 { case 39。 39。 :return 1。 break。 case 39。 39。 :return 1。 break。 case 39。 =39。 :return 0。 break。 default:return 2。 break。 } } void main() { char string[MAX]。 //for the sentence to be ananlyse char *ch=new char [MAX]。 //the mergeing string stack s。 //for the merge stack (39。 39。 )。 //init the stack char a。 //store the letter need to be judge int strp。 //point to the letter of the string int statop。 //point to the top of the stack int statopvt。 //point to the top VT cout*****优先关系表 :********endl。 DispCost()。 cout*********************************************************endl。 cout请输入一个字符串 (以 39。 39。 结束 ): endl。 (string,MAX)。 coutThe stack:39。 \t39。 The actionendl。 a=string[0]。 //init the pointers strp=0。 statop=()1。 statopvt=statop。 while(a!=39。 39。 ) //The analysing progress is as following: { //if the letter39。 s priority is litter than the top start merge a=string[strp]。 // get the letter if((a==39。 *39。 )amp。 amp。 (string[strp+1]==39。 *39。 )) { a=39。 !39。 strp++。 } if(IsVT((statop))) statopvt=statop。 else statopvt=statop1。 14 //if the letter39。 s priority is greater than the top the push it while(IsVT(a)amp。 amp。 (SearchCost((statopvt),a)==1))//the topvt is greater than the letter the can not push then merge { ()。 //show the stack before merging int hi。编译课程设计报告书
相关推荐
资源优势。 二、制约因素 ,世界自然基金会于 2020 年在草坝村推行了绿色大米种植项目,绿色大米的种植,对于化肥和农药的施用有一定的限制,直接导致水稻减产,稻民收入随之降低。 2.绿色大米推行至今已有三年之久,种植方法已经得到普遍推广,并且绿色大 米已经通过了国家有关机构的鉴定,各项指标均符合绿色食品标准,但是由于销路没有打通,致使绿色大米的经济效益没有体现出来。 三、结论 综上所述
ail、聊天室和 bbs 等在网络上讨论任何问题。 可以实现异步的交流与学习 学生可以根据教师的安排和自己的实际情况进行学习,克服传统教学中“一刀切”的现象。 学生通过网络能及时了解到自己的进步和不足,及时地调整学习。 利用网络,学生可以在任何时间进行学习或获得在线帮助,实现真正的个别化学习。 此外,网络中有大量的个性化教育资源,如专题网络、教育专家个人网页、专题新闻、专业化的电子杂志等
端口写“ 1”时,内部上拉电阻把端口拉高,此时可以作为输入口使用。 作为输入使用时,被外部拉低的引脚由于内部电阻的原因,将输出电流。 P3 口亦作为 AT89C51 特殊功能(第二功能)使用, P3 口功能如表2所示。 在 flash 编程和校验时, P3口也接收一些控制信号。 表 2 P3 口的第二种功能说明表 引脚号 第二功能 RXD(串行输入) TXD (串行输出 ) INT0 (外部中断
2 通过 集料 177。 4%,且不超出标准级配范围 3 通过 的集料 177。 2% 4 通过 的粉料 177。 1% 5 沥青用量(油石化) 177。 % 6 空隙率 177。 % 7 饱和度 177。 5% 8 稳定度、流值 按表“热拌沥青混合料马歇尔试验技术标准规定” F、注意高速拌和楼振动筛筛孔,使每层筛网余石料大致相等,避免溢料和待料影响产量。 ( 2)运输设备 A、根据实地考察