资源描述:
《TP314 Crafting A Compiler 2nd》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、1IntroductionThischapterpresentsthebasicsofcompilerhistoryandorganization.WebegininSection1.1withanoverviewofcompilersandthehistoryoftheirdevelop-ment.Fromthere,weexplaininSection1.2whatacompilerdoesandhowvariouscompilerscanbedistinguishedfromeachother:bythekindofmachinec
2、odetheygenerateandbytheformatofthetargetcodetheygenerate.InSection1.3,wediscussakindoflanguageprocessorcalledaninterpreterandexplainhowaninterpreterdiffersfromacompiler.Section1.4discussesthesyntax(structure)andsemantics(meaning)ofprograms.Next,inSection1.5,wediscusstheta
3、sksthatacompilermustperform,primarilyanalysisofthesourceprogramandsynthesisofatargetprogram.Thatsectionalsocoversthepartsofacompiler,discussingeachinsomedetail:scanner,parser,typechecker,optimizerandcodegenerator.InSection1.6,wediscussthemutualinteractionofcompilerdesigna
4、ndpro-gramminglanguagedesign.Similarly,inSection1.7theinfluenceofcomputerarchitectureoncompilerdesigniscovered.Section1.8introducesanumberofimportantcompilervariants,includingdebugginganddevelopmentcompilers,optimizingcompilers,andretargetablecompilers.Finally,inSection1.9
5、,weconsiderprogramdevelopmentenviron-mentsthatintegrateacompiler,editoranddebuggerintoasingletool.Donotcopy1.1OverviewandHistoryofCompilationCompilersarefundamentaltomoderncomputing.Theyactastranslators,trans-forminghuman-orientedprogramminglanguagesintocomputer-orientedm
6、a-chinelanguages.Tomostusers,acompilercanbeviewedasa“blackbox”thatperformsthetransformationillustratedinFigure1.1.Acompilerallowsvirtuallyallcomputeruserstoignorethemachine-dependentdetailsofmachine12Chapter1.IntroductionReservingspacefor:UserViewFigure1.1:Auser'sviewofac
7、ompiler.language.Compilersthereforeallowprogramsandprogrammingexpertisetobemachine-independent.Thisisaparticularlyvaluablecapabilityinanageinwhichthenumberandvarietyofcomputerscontinuetogrowexplosively.Thetermcompilerwascoinedintheearly1950sbyGraceMurrayHopper.Translation
8、wasthenviewedasthe“compilation”ofasequenceofmachine-languagesubprogramsselectedfromalibrary.Comp