第一范文网 - 专业文章范例文档资料分享平台

天津理工大学编译原理实验3:语义分析及中间代码生成

来源:用户分享 时间:2025/8/26 17:35:29 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

}

else if(production==\ { char sx='7'; (*index)++; pushstack(stack,pointer,state_stack,pointer_state,c,sx,0); }

else if(production==\ { char sx='8'; (*index)++; pushstack(stack,pointer,state_stack,pointer_state,c,sx,0); }

else if(production==\ { char sx='9'; (*index)++; pushstack(stack,pointer,state_stack,pointer_state,c,sx,0); }

else if(production==\ { char sx='a'; (*index)++; pushstack(stack,pointer,state_stack,pointer_state,c,sx,0); }

else if(production==\ { char sx='b'; (*index)++; pushstack(stack,pointer,state_stack,pointer_state,c,sx,0); }

else if(production==\ { char sx='i'; (*index)++; pushstack(stack,pointer,state_stack,pointer_state,c,sx,0); }

else if(production==\ { int po=(*pointer);//用P规约该表达式,有效变量在E的endchar中,需要找到E的位置,即下面的操作 string st=stack[po].endchar;//对应 F po-=2; string se=stack[po].endchar;//在规约之前记录下要规约的字符所代表的变量。对应 T

tsize++;//新增临时变量 t[tsize].num=tsize+1;//下面四个表达式是按照上面的规约式进行的赋值 t[tsize].operate='+'; t[tsize].var1=se; t[tsize].var2=st; cout<<\ int p=(*pointer_state); p-=3; char second=state_stack[p]; int i=getraw(second); int j=getcol('E'); char c_out=getraw_content(table[i][j]); cout<<\用E-->E+T规约且\ popstack(state_stack,pointer_state,3); popstackc(stack,pointer,3); char c='E';//str[(*index)]; pushstack(stack,pointer,state_stack,pointer_state,c,c_out,1); string s=get_tx(t[tsize].num); stack[(*pointer)].endchar=s;//把保存E+T规约的结果的变量保存至当前字符的终结符 }

else if(production==\ { int po=(*pointer);//用P规约该表达式,有效变量在E的endchar中,需要找到E的位置,即下面的操作 string st=stack[po].endchar;//对应 T po-=2; string se=stack[po].endchar;//在规约之前记录下要规约的字符所代表的变量。对应 E tsize++;//新增临时变量 t[tsize].num=tsize+1;//下面四个表达式是按照上面的规约式进行的赋值 t[tsize].operate='-'; t[tsize].var1=se; t[tsize].var2=st; cout<<\ int p=(*pointer_state); p-=3; char second=state_stack[p]; int i=getraw(second); int j=getcol('E'); char c_out=getraw_content(table[i][j]); cout<<\用E-->E-T规约且\ popstack(state_stack,pointer_state,3);

天津理工大学编译原理实验3:语义分析及中间代码生成.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c6tiex6p52i5zpak1cslt1is530855j00ibw_3.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top