清华大学软件学院编译原理课件pdf.pdf
上传人:qw****27 上传时间:2024-09-12 格式:PDF 页数:54 大小:2MB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

清华大学软件学院编译原理课件pdf.pdf

清华大学软件学院编译原理课件pdf.pdf

预览

免费试读已结束,剩余 44 页请下载文档后查看

15 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

THSS341001622010/4301PrinciplesofCompilation王朝坤IISE@TsinghuaTHSS341001622010/4301Chap.1IntroductionChaokunWangIISE@TsinghuaOutlineTHSS341001622010/4301•What–什么是编译和编译器•Why•CourseInfo.•PL–编译与解释的区别和联系•History•Contents•编译各阶段的内容31.1Computer&SoftwareTHSS341001622010/43014CloudComputingTHSS341001622010/4301•PigLatin–PigLatinisadataflowlanguageratherthanproceduralordeclarative.–Usercodeandexistingbinariescanbeincludedalmostanywhere.–Metadatanotrequired,butusedwhenavailable.–Supportfornestedtypes.–OperatesonfilesinHDFS.5THSS341001622010/43016软件开发THSS341001622010/4301•程序开发工具??•如何从编辑器中的文本到可执行程序的??7Alanguage-processingsystemTHSS341001622010/43018Whatis…THSS341001622010/4301•Compilation(编译)–Compilationistheprocesswherebyonecomputerlanguageistranslatedintoanother(usuallysimplerandmorelow-leveli.e.machineorientated)language–Traditionally,programsinahigh-levelcomputerlanguage(e.g.Pascal,C,Lisp)arecompiledintoassemblylanguage(essentiallymachinecode)•Compiler(编译器)–Theprogramthatdoesthetranslationisknownasacompiler.9CompilersTHSS341001622010/4301•Simplystated,acompilerisaprogramthatreadsaprogramwritteninonelanguage—thesourcelanguage—andtranslateitintoanequivalentprograminanotherlanguage—thetargetlanguage.Asanimportantpartofthistranslationprocess,thecompilerreportstoitsuserthepresenceoferrorsinthesourceprogram.10PreprocessorsTHSS341001622010/4301•Preprocessorsproduceinputtocompilers.Theymayperformthefollowingfunctions.•Macroinclusion.•Fileinclusion.•“Rational”preprocessors.•Languageextensions.11AssemblersTHSS341001622010/4301•Somecompilersproduceassemblycodethatispassedtoanassemblerforfurtherprocessing.•Othercompilersperformthejoboftheassembler,producingrelocatablemachinecodethatcanbepasseddirectlytotheloader/link-editor.•Therelationshipbetweenassemblyandmachinecode–Assemblycodeismnemonicversionofmachinecode,–namesareusedinsteadofbinarycodesforope