编译原理编译原理编译原理 (37).ppt

上传人:刘静 文档编号:84314525 上传时间:2023-04-04 格式:PPT 页数:5 大小:234.50KB
返回 下载 相关 举报
编译原理编译原理编译原理 (37).ppt_第1页
第1页 / 共5页
编译原理编译原理编译原理 (37).ppt_第2页
第2页 / 共5页
点击查看更多>>
资源描述

《编译原理编译原理编译原理 (37).ppt》由会员分享,可在线阅读,更多相关《编译原理编译原理编译原理 (37).ppt(5页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、CompilerS1Follow Sets Given a nonterminal A,the set Follow(A),consisting of terminals and$,is defined as follows.1.If A is the start symbol,then$is in Follow(A).2.If there is a production B A,then First()is in Follow(A).3.If there is a production B A such that is in the First(),then Follow(A)contain

2、s Follow(B).oIf B A,Follow(A)contains Follow(B)CompilerS2Example 4.9First(exp)=(,numberFirst(addop)=+,-First(term)=(,numberFirst(mulop)=*First(factor)=(,number(1)exp exp addop term(2)exp term(3)addop +(4)addop -(5)term term mulop factor(6)term factor(7)mulop *(8)factor (exp)(9)factor numberFollow(ex

3、p)=Follow(addop)=Follow(term)=Follow(factor)=Follow(mulop)=,+,-(,number$,+,-,*(,number$,+,-,*,),),)CompilerS3Example 4.9xxexp exp addop term|termaddop +|-term term mulop factor|factormulop *factor (exp)|number(1)exp exp addop term(2)exp term(3)addop +(4)addop -(5)term term mulop factor(6)term factor

4、(7)mulop *(8)factor (exp)(9)factor numberRewrite each choice separately.Note,there is no -productions.CompilerS4Example 4.13xxFollow(statement)=Follow(if-stmt)=Follow(else-part)=Follow(exp)=(1)statement if-stmt(2)statement other(3)if-stmt if(exp)statement else-part(4)else-part else statement(5)else-

5、part (6)exp 0(7)exp 1First(statement)=if,otherFirst(if-stmt)=if First(else-part)=else,First(exp)=0,1$),else$,else,elseCompilerS5Example 4.10statement if-stmt|otherif-stmt if(exp)statement else-partelse-part else statement|exp 0|1(1)statement if-stmt(2)statement other(3)if-stmt if(exp)statement else-part(4)else-part else statement(5)else-part (6)exp 0(7)exp 1

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 大学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com