Abstract data types Laboratorio Multimediale抽象数据类型该ppt课件.ppt

Abstract data types Laboratorio Multimediale抽象数据类型该ppt课件.ppt

ID:58894532

大小:372.00 KB

页数:65页

时间:2020-09-30

Abstract data types  Laboratorio Multimediale抽象数据类型该ppt课件.ppt_第1页
Abstract data types  Laboratorio Multimediale抽象数据类型该ppt课件.ppt_第2页
Abstract data types  Laboratorio Multimediale抽象数据类型该ppt课件.ppt_第3页
Abstract data types  Laboratorio Multimediale抽象数据类型该ppt课件.ppt_第4页
Abstract data types  Laboratorio Multimediale抽象数据类型该ppt课件.ppt_第5页
资源描述:

《Abstract data types Laboratorio Multimediale抽象数据类型该ppt课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、ParsingParsingCalculategrammaticalstructureofprogram,likediagrammingsentences,where:Tokens=“words”Programs=“sentences”Forfurtherinformation,read:Aho,Sethi,Ullman,“Compilers:Principles,Techniques,andTools”(a.k.a,the“DragonBook”)OutlineofcoverageContext-freegrammarsParsingTa

2、bularParsingMethodsOnepassTop-downBottom-upYaccParser:extractsgrammaticalstructureofprogramfunction-defnameargumentsstmt-listmainstmtexpressionoperatorexpressionexpressionvariablestringcout<<“hello,world”Context-freelanguagesGrammaticalstructuredefinedbycontext-freegramm

3、arstatementlabeled-statement

4、expression-statement

5、compound-statementlabeled-statementident:statement

6、caseconstant-expression:statementcompound-statement{declaration-liststatement-list}terminalnon-terminal“Context-free”=onlyonenon-terminalinleft-partParsetreesParsetree=t

7、reelabeledwithgrammarsymbols,suchthat:IfnodeislabeledA,anditschildrenarelabeledx1...xn,thenthereisaproduction Ax1...xn“ParsetreefromA”=rootlabeledwithA“Completeparsetree”=allleaveslabeledwithtokensParsetreesandsentencesFrontieroftree=labelsonleaves(inleft-to-rightorder)F

8、rontieroftreefromSisasententialformFrontierofacompletetreefromSisasentenceLEaL;E“Frontier”ExampleG:LL;E

9、E Ea

10、bSyntaxtreesfromstartsymbol(L):aa;Ea;b;bLEaLEaL;ELEaL;EbLEb;Sententialforms:DerivationsAlternatedefinitionofsentence:Given,inV*,sayisaderivationstepif

11、’’’and=’’’,whereAisaproductionisasententialformiffthereexistsaderivation(sequenceofderivationsteps)S(alternatively,wesaythatS*)Twodefinitionsareequivalent,butnotethattherearemanyderivationscorrespondingtoeachparsetreeAnotherexampleH:LE;L

12、E Ea

13、bLEaLEa

14、L;ELEaL;EbLEb;AmbiguityForsomepurposes,itisimportanttoknowwhetherasentencecanhavemorethanoneparsetreeAgrammarisambiguousifthereisasentencewithmorethanoneparsetreeExample:EE+E

15、E*E

16、idEEEEEididid+*EEEEEididid+*Ifethenifbthendelsef{intx;y=0;}A.b.c=d;Id->s

17、s.idE->E+T->E+T+T->T

18、+T+T->id+T+T->id+T*id+T->id+id*id+T->id+id*id+idAmbiguityAmbiguityisafunctionofthegrammar

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。