编译原理上下无关文法与文法分析课件_第1页
编译原理上下无关文法与文法分析课件_第2页
编译原理上下无关文法与文法分析课件_第3页
编译原理上下无关文法与文法分析课件_第4页
编译原理上下无关文法与文法分析课件_第5页
已阅读5页,还剩79页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Chapter3Context-FreegrammarsandParsingInstructorJianhuiYueSoftwareCollegeSCUcompilerscu2lcnChapter31IntroductionParsingisthetaskofdeterminingthesyntax,orstructure,ofaprogramItisalsocalledsyntaxanalysisThesyntaxofaprogramminglanguageisusuallyivenbythegrammarrulesofacontext-freegrammaITherulesofcontext-freegrammararerecursiveDatastructuresrepresentingthesyntacticstructurearealsorecursive-aparsetreeorsyntaxtreeIntroduction2TheParsingProcessparserScqucnceoftokenSyntaxtreeUsually,thesequenceoftokensisnotanexplicitinputparameter,buttheparsercallsascannerproceduresuchasgetTokentofetchthenexttokenfromtheinputasitisneededduringtheparserprocessTheParsingProcess3Context-FreeGrammarsAcontext-freegrammarisaspecificationforthesyntacticstructureofaprogramminglanguageContext-freegrammarinvolvesrecursiverules·Exampleintegerarithmeticexpressionswithadditions,subtraction,andmultiplicationoperationsexp>expopexpI(exp)inumberOp->+|-1非Context-FreeGrammars4BNFNamesarewritteninitalicexp->expopexpI(exp)InumbermetasymbolforchoiceConcatenationisusedasastandardoperation°Norepetitions-isusedtoexpressthedefinitionsofnamesRegularexpressionsareusedascomponentsThenotationwasdevelopedbyJohnBackusandadaptedbyPeterNaurThegrammarrulesinthisformaresaidtobeinBackus-NaurformorbneBNF5编译原理上下无关文法与文法分析课件6编译原理上下无关文法与文法分析课件7编译原理上下无关文法与文法分析课件8编译原理上下无关文法与文法分析课件9编译原理上下无关文法与文法分析课件10编译原理上下无关文法与文法分析课件11编译原理上下无关文法与文法分析课件12编译原理上下无关文法与文法分析课件13编译原理上下无关文法与文法分析课件14编译原理上下无关文法与文法分析课件15编译原理上下无关文法与文法分析课件16编译原理上下无关文法与文法分析课件17编译原理上下无关文法与文法分析课件18编译原理上下无关文法与文法分析课件19编译原理上下无关文法与文法分析课件20编译原理上下无关文法与文法分析课件21编译原理上下无关文法与文法分析课件22编译原理上下无关文法与文法分析课件23编译原理上下无关文法与文法分析课件24编译原理上下无关文法与文法分析课件25编译原理上下无关文法与文法分析课件26编译原理上下无关文法与文法分析课件27编译原理上下无关文法与文法分析课件28编译原理上下无关文法与文法分析课件29编译原理上下无关文法与文法分析课件30编译原理上下无关文法与文法分析课件31编译原理上下无关文法与文法分析课件32编译原理上下无关文法与文法分析课件33编译原理上下无关文法与文法分析课件34编译原理上下无关文法与文法分析课件35编译原理上下无关文法与文法分析课件36编译原理上下无关文法与文法分析课件37编译原理上下无关文法与文法分析课件38编译原理上下无关文法与文法分析课件39编译原理上下无关文法与文法分析课件40编译原理上下无关文法与文法分析课件41编译原理上下无关文法与文法分析课件42Chapter3Context-FreegrammarsandParsingInstructorJianhuiYueSoftwareCollegeSCUcompilerscu2lcnChapter343IntroductionParsingisthetaskofdeterminingthesyntax,orstructure,ofaprogramItisalsocalledsyntaxanalysisThesyntaxofaprogramminglanguageisusuallyivenbythegrammarrulesofacontext-freegrammaITherulesofcontext-freegrammararerecursiveDatastructuresrepresentingthesyntacticstructurearealsorecursive-aparsetreeorsyntaxtreeIntroduction44TheParsingProcessparserScqucnceoftokenSyntaxtreeUsually,thesequenceoftokensisnotanexplicitinputparameter,buttheparsercallsascannerproceduresuchasgetTokentofetchthenexttokenfromtheinputasitisneededduringtheparserprocessTheParsingProcess45Context-FreeGrammarsAcontext-freegrammarisaspecificationforthesyntacticstructureofaprogramminglanguageContext-freegrammarinvolvesrecursiverules·Exampleintegerarithmeticexpressionswithadditions,subtraction,andmultiplicationoperationsexp>expopexpI(exp)inumberOp->+|-1非Context-FreeGrammars46BNFNamesarewritteninitalicexp->expopexpI(exp)InumbermetasymbolforchoiceConcatenationisusedasastandardoperation°Norepetitions-isusedtoexpressthedefinitionsofnamesRegularexpressionsareusedascomponentsThenotationwasdevelopedbyJohnBackusandadaptedbyPeterNaurThegrammarrulesinthisformaresaidtobeinBackus-NaurformorbneBNF47编译原理上下无关文法与文法分析课件48编译原理上下无关文法与文法分析课件49编译原理上下无关文法与文法分析课件50编译原理上下无关文法与文法分析课件51编译原理上下无关文法与文法分析课件52编译原理上下无关文法与文法分析课件53编译原理上下无关文法与文法分析课件54编译原理上下无关文法与文法分析课件55编译原理上下无关文法与文法分析课件56编译原理上下无关文法与文法分析课件57编译原理上下无关文法与文法分析课件58编译原理上下无关文法与文法分析课件59编译原理上下无关文法与文法分析课件60编译原理上下无关文法与文法分析课件61编译原理上下无关文法与文法分析课件62编译原理上下无关文法与文法分析课件63编译原理上下无关文法与文法分析课件64编译原理上下无关文法与文法分析课件65编译原理上下无关文法与文法分析课件66编译原理上下无关文法与文法分析课件67编译原理上下无关文法与文法分析课件68编译原理上下无关文法与文法分析课件69编译原理上下无关文法与文法分析课件70编译原理上下无关文法与文法分析课件71编译原理上下无关文法与文法分析课件72编译原理上下无关文法与文法分析课件73编译原理

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论