- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Programming Languages Chapter 2 Syntax程序设计语言2章语法
2.2 Extended BNF (EBNF) BNF: recursion to represent iteration EBNF: additional metacharacters represent iteration { } braces: show a series of zero or more occurrences ( ) parens: pick exactly one from the enclosed list [ ] brackets: pick zero or one from the enclosed list How are metacharacters distinguished from terminal symbols? Compare BNF/EBNF Examples BNF Expr → Term | Exp + Term | Exp - Term IfStatement →if ( Exp ) Statement | if ( Exp ) Statement else Statement EBNF Expr → Term { ( + | - ) Term } IfStatement →if ( Expr ) Statement [ else Statement ] C-style EBNF C-style EBNF lists alternatives on separate lines and uses opt to signify optional parts. e.g., IfStatement: if ( Expression ) Statement ElsePartopt ElsePart: else Statement EBNF to BNF We can always rewrite an EBNF grammar as a BNF grammar. e.g., A → x { y } z can be rewritten: A → x A z A → ε | y A (Rewriting EBNF rules with ( ), [ ] is left as an exercise.) Syntax Diagram for Expressions with Addition – Figure 2.6 Syntax diagrams are another way to describe grammar rules. Popularized when they were used to describe Pascal grammar. All Three are Equally Powerful BNF is considered equivalent to context-free grammars because it can express any rule in the grammar EBNF is no more (or less) powerful or expressive than BNF. Its virtue is compactness. Syntax diagrams are equally expressive. Summary Preview Grammars BNF notation Grammars parse trees Grammars, parse trees, associativity precedence Ambiguity in grammars Next up: Clite syntax Lexical and concrete syntax Compilers interpreters Abstract syntax Can you construct another tree for this expression, perhaps using expr - expr – term as the first derivation? Copyright ? 2006 The McGraw-Hill Companies, Inc. Programming Languages2nd editionTucker and Noonan Chapter 2 Syntax A language that is simple to parse for the compiler is also simple to parse for the human prog
您可能关注的文档
- Presentacin de PowerPoint javerianapresentaci和243N的PowerPoint哈韦.co.ppt
- Presentacin de PowerPoint Investigacin y Ensayo243 presentaci && PowerPoint investigaci N N和测试243.ppt
- Presentacin de PowerPoint La Molinapresentaci PowerPoint和243 莫里纳.ppt
- Presentacin de PowerPoint Medicina Critica Peditrica公司介绍243n de PowerPoint医学·& 225批评占主导.pptx
- Presentacin de PowerPoint OoCitiespresentaci和# 243;N的PowerPoint oocities.ppt
- Presentacin de PowerPoint puntofertilpresentaci & n 243 puntofertil PowerPoint.ppt
- Presentacin de PowerPoint movistarpresentaci PowerPoint和243 星.ve.ppt
- Presentacin de PowerPoint readingtonpresentaci & n 243 readington PowerPoint.k12.nj.us.ppt
- Presentacin de PowerPoint PAHOpresentaci & n 243 PAHO PowerPoint.ppt
- Presentacin de PowerPoint palermopresentaci & #巴勒莫243 PowerPoint.ppt
- Programming and Problem Solving with C++, 2e编程用C++解决问题2E.ppt
- Programming Languages Principles and Practice, 2nd ed Kenneth程序设计语言原理与实践第二版肯尼斯.ppt
- Programming Outdoor Distributed Embedded Systems室外分布式嵌入式系统.ppt
- Programming the RCX UW Courses Web Server编程的RCX注册课程的Web服务器.ppt
- Programming with Alice Swikis on coweb爱丽丝在coweb swikis编程.cc.ppt
- Programming with Scratch galaxy用划痕编程.cs.lamar.ppt
- Programming with Alice New Mexico MESA编程与爱丽丝新墨西哥梅萨.ppt
- Programming support for distributed clustercomputing规划支持分布式集群计算.ppt
- Progress Measures for Young Deaf HH Children青年聋人HH孩子进步的措施.ppt
- Programming support for distributed clustercomputing VU分布式集群计算似曾相识的编程支持.ppt
原创力文档


文档评论(0)