(4.5)--Samuel's Ch3_4编译原理与实践英文版.ppt

上传人:奉*** 文档编号:96452418 上传时间:2023-11-29 格式:PPT 页数:11 大小:434KB
返回 下载 相关 举报
(4.5)--Samuel's Ch3_4编译原理与实践英文版.ppt_第1页
第1页 / 共11页
(4.5)--Samuel's Ch3_4编译原理与实践英文版.ppt_第2页
第2页 / 共11页
点击查看更多>>
资源描述

《(4.5)--Samuel's Ch3_4编译原理与实践英文版.ppt》由会员分享,可在线阅读,更多相关《(4.5)--Samuel's Ch3_4编译原理与实践英文版.ppt(11页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、CompilerS1Chapter 3Context-Free Grammars and Parsing Extended BNF Notation CompilerS2Extended BNF Notation(EBNF)o repetitions A and A CompilerS3Left and Right RecursionoLeft recursive grammar:oA A|nEquivalent to *oA oRight recursive grammar:oA A|nEquivalent to *oA CompilerS4Extended BNF Notation(EBN

2、F)o repetitions A and A o optional constructs statement if-stmt|otherif-stmt if(exp)statement else statement exp 0|1statement if-stmt|otherif-stmt if(exp)statement|if(exp)statement else statementexp 0|1CompilerS5Syntax DiagramsoGraphical representations for visually representing EBNF rules are calle

3、d syntax diagrams.oThey consist of boxes representing terminals and nonterminals,arrowed lines representing sequencing and choices,and nonterminal labels for each diagram representing the grammar rule defining that nonterminal.oA round or oval box is used to indicate terminals in a diagram,while a s

4、quare or rectangular box is used to indicate nonterminals.CompilerS6Syntax Diagrams(cont)oAs an example,consider the grammar ruleofactor (exp)|numberoThis is written as a syntax diagram in the following way:CompilerS7Syntax Diagrams(cont)oSyntax diagrams are written from the EBNF rather than the BNF

5、,so we need diagrams representing repetition and optional constructs.Given a repetition such asoA B oThe corresponding syntax diagram is usually drawn as follow:CompilerS8Syntax Diagrams(cont)oAn optional construct such asoA B oIs drawn as:CompilerS9Exampleexp exp addop term|termaddop +|term term mu

6、lop factor|factormulop *factor (exp)|numberexp term addop term addop +|term factor mulop factor mulop *factor (exp)|numberCompilerS10Examplestatement if-stmt|otherif-stmt if(exp)statement else statement exp 0|1statement if-stmt|otherif-stmt if(exp)statement|if(exp)statement else statementexp 0|1CompilerS11Homework1.21.31.72.12.22.42.52.82.122.172.243.33.53.63.24

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

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

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

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁