Un compilateur () est un programme informatique qui convertit le code source écrit dans un langage de programmation (langage d'origine) dans un autre langage de programmation (langage cible).

Compilateur

Un compilateur () est un programme informatique qui convertit le code source écrit dans un langage de programmation (langage d'origine) dans un autre langage de programmation (langage cible).

exécution du programme

concepts de base

  • code
  • Traducteur
    • Compilateur
    • optimisation du compilateur
  • langue intermédiaire
  • exécution du programme
    • système d'exécution
      • Délai d'exécution
    • fichier exécutable
    • machine virtuelle

type de code

  • code source
  • code cible
  • bytecode
  • langage machine
  • microprogramme

Stratégie de compilation

  • Compilation juste à temps ( JIT )
    • Suivez la compilation juste à temps
  • Compilation anticipée ( AOT )
  • code source vers compilateur de code source
  • Recompilation dynamique

Environnement d'exploitation bien connu

  • Android RuntimeART
  • Temps d'exécution du langage commun ( CLR )
  • crt0
  • Machine virtuelle Java ( JVM )
  • V8
    • Noeud.js
  • PyPy
  • Moteur Zend

Compilateurs et chaînes d'outils célèbres

  • Suite du compilateur GNU ( GCC )
  • LLVM
    • Bruit

它主要的目的是将便于人编写、阅读、维护的高级计算机语言所写作的原始码程序,翻译为计算机能解读、运行的低阶机器语言的程序,也就是执行档。编译器将原始程序(source program)作为输入,翻译产生使用目标语言(target language)的等价程序。源代码一般为高阶语言(High-level language),如PascalCC++C# Java等,而目标语言则是汇编语言或目标机器的目标代码(Object code),有时也称作机器代码Machine code)。

一个现代编译器的主要工作流程如下:

源代码source code)→ 预处理器preprocessor)→ 编译器compiler)→ 汇编程序assembler)→ 目标代码object code)→ 链接器linker)→ 执行档executables),最后打包好的档案就可以给计算机去判读执行了。

历史

早期的计算机软件都是用汇编语言直接编写的,这种状况持续了数年。当人们发现为不同类型的中央处理器CPU)编写可重用软件的开销要明显高于编写编译器时,人们发明了高级编程语言。由于早期的计算机的内存很少,当大家实现编译器时,遇到了许多技术难题。

大约在20世纪50年代末期,与机器无关的编程语言被首次提出。随后,人们开发了几种实验性质的编译器。第一个编译器是由美国女性计算机科学家葛丽丝·霍普Grace Murray Hopper)于1952年为A-0 系统编写的。但是1957年由任职于IBM的美国计算机科学家约翰·巴科斯(John Warner Backus)领导的FORTRAN则是第一个被实作出具备完整功能的编译器。1960年,COBOL成为一种较早的能在多种架构下被编译的语言。

高级语言在许多领域流行起来。由于新的编程语言支持的功能越来越多,计算机的架构越来越复杂,这使得编译器也越来越复杂。

早期的编译器是用汇编语言编写的。首个能编译自己源程序的编译器是在1962年由麻省理工学院的HartLevin制作的。从20世纪70年代起,实现能编译自己源程序的编译器变得越来越可行,不过还是用PascalC语言来实现编译器更加流行。制作某种语言的第一个能编译器,要么需要用其它语言来编写,要么就像HartLevin制作Lisp编译器那样,用解释器来运行编译器。

教学用的编译器

编译器的构造与优化是计算机专业的大学课程,课程名称一般为「编译原理」或「编译程序」。通常在课程中包含了如何实现一种教学用程序语言的编译器。一个著名的例子是20世纪70年代,瑞士计算器科学家尼克劳斯·维尔特()用于讲解编译器的构造时使用的PL/0编译器。尽管它很简单,PL/0编译器介绍了这个领域的几个有影响的概念:

  1. 逐步求精的程序开发(也是 1971年 Wirth 的论文的标题)
  2. 使用递归下降解析器
  3. 使用EBNF指定语言的语法。
  4. 代码生成器产生便携P-code
  5. 在自举问题的正式描述中使用T-diagram。

分类

编译器的一种分类方式是按照生成代码所运行的系统平台划分,这个平台称为目标平台。

有一些编译器输出的代码,将运行于与编译器所在相同类型的计算机和操作系统之上,这种编译器叫做本地编译器。输出可以运行于不同的平台之上的编译器,叫做交叉编译器。由于嵌入式系统通常没有软件开发环境,因此,为这类系统开发软件时,通常需要使用交叉编译器。

编译器所输出于虚拟机上运行之代码,编译器和编译器输出的运行平台有可能相同,也有可能不同。因此,对于这类编译器,不去区分它是本地编译器还是交叉编译器。

参考文献

    1.  Chakraborty, P., Saxena, P. C., Katti, C. P., Pahwa, G., Taneja, S. A new practicum in compiler construction. Computer Applications in Engineering Education, In Press. http://onlinelibrary.wiley.com/doi/10.1002/cae.20566/pdf 页面存档备份,存于)
    2.  . 原始内容存档于2007-07-17.

延伸阅读

  • LLVM community. . LLVM Documentation. [17 June 2016]. (原始内容存档于2021-05-01).
  • Compiler textbook references A collection of references to mainstream Compiler Construction Textbooks
  • Aho, Alfred V.; Sethi, Ravi; Ullman, Jeffrey D. 1st. Addison-Wesley. 1986. ISBN 9780201100884.
  • Allen, Frances E. . IBM Journal of Research and Development (IBM). September 1981, 25 (5): 535–548. doi:10.1147/rd.255.0535.
  • Allen, Randy; Kennedy, Ken. . Morgan Kaufmann Publishers. 2001. ISBN 978-1-55860-286-1.
  • Appel, Andrew Wilson. 2nd. Cambridge University Press. 2002. ISBN 978-0-521-82060-8.
  • Appel, Andrew Wilson. . Cambridge University Press. 1998 [2020-01-11]. ISBN 978-0-521-58274-2. (原始内容存档于2021-04-27).
  • Bornat, Richard. (PDF). Macmillan Publishing. 1979 [2020-01-11]. ISBN 978-0-333-21732-0. (原始内容 (PDF)存档于2007-06-15).
  • Cooper, Keith Daniel; Torczon, Linda. 2nd. Amsterdam: Elsevier/Morgan Kaufmann. 2012: 8. ISBN 9780120884780. OCLC 714113472.
  • McKeeman, William MarshallHorning, James J.; Wortman, David B. . Englewood Cliffs, NJPrentice-Hall. 1970. ISBN 978-0-13-155077-3.
  • Muchnick, Steven. . Morgan Kaufmann Publishers. 1997 [2020-01-11]. ISBN 978-1-55860-320-2. (原始内容存档于2021-02-23).
  • Scott, Michael Lee. 2nd. Morgan Kaufmann. 2005 [2020-01-11]. ISBN 978-0-12-633951-2. (原始内容存档于2021-04-27).
  • Srikant, Y. N.; Shankar, Priti. . CRC Press. 2003 [2020-01-11]. ISBN 978-0-8493-1240-3. (原始内容存档于2021-04-27).
  • Terry, Patrick D. . International Thomson Computer Press. 1997 [2020-01-11]. ISBN 978-1-85032-298-6. (原始内容存档于2015-09-14).
  • Wirth, Niklaus. (PDF). Addison-Wesley. 1996 [2020-01-11]. ISBN 978-0-201-40353-4. (原始内容 (PDF)存档于2017-02-17).

参见

  • 链接器
  • 直译器

外部连结

维基词典中的词条「」。

维基教科书中的相关电子:Compiler Construction

维基共享资源中相关的多媒体资源:编译程序

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.

 

 

 

Je suppose que tu aimes

Origine blog.csdn.net/weixin_40191861/article/details/132823213
conseillé
Classement