Compiler - 编译器
The first compiler was build by John Backum and his group between 1954 and 1957 at IBM.
编译器就是将高级语言翻译为低级语言的程序。
FORTRAN one was the first successful high level language
FORTRAN语言是Formula Translation的缩写,意为“公式翻译”。它是为科学、工程问题或企事业管理中的那些能够用数学公式表达的问题而设计的,其数值计算的功能较强。
FORTRAN语言是世界上第一个被正式推广使用的高级语言。它是1954年被提出来的,1956年开始正式使用,直到2021年已有六十年的历史,但仍历久不衰,它始终是数值计算领域所使用的主要语言。
1. What is a Compiler?
A compiler is a computer program which helps you transform source code written in a high-level language into low-level machine language. It translates the code written in one programming language to some other language without changing the meaning of the code. The compiler also makes the end code efficient which is optimized for execution time and memory space.
编译器是一种计算机程序,可以帮助你将以高级语言编写的源代码转换为低级机器语言。它将以一种编程语言编写的代码转换为另一种语言,而无需更改代码的含义。编译器对代码执行时间和存储空间进行优化,使最终代码高效率。
The compiling process includes basic translation mechanisms and error detection. Compiler process goes through lexical, syntax, and semantic analysis at the front end, and code generation and optimization at a back end.
编译过程包括基本的转换机制和错误检测。编译器过程在前端进行词法,语法和语义分析,在后端进行代码生成和优化。
front end: lexical, syntax, and semantic analysis
back end: code generation and optimization
lexical ['leksɪk(ə)l]:adj. 词汇的
syntax ['sɪntæks]:n. 句法,句法规则,语构
semantic [sə'mæntɪk]:adj. 语义的
2. 编译器类型
2.1 Single Pass Compilers
In single pass Compiler source code directly transforms into machine code. For example, Pascal language.
2.2 Two Pass Compilers
Two pass Compiler is divided into two sections, viz.
- Front end: It maps legal code into Intermediate Representation (IR).
- Back end: It maps IR onto the target machine
The Two pass compiler method also simplifies the retargeting process. It also allows multiple front ends.
videlicet [vɪ'deləsɪt]:adv. 即
viz. [vɪz]:adv. 即,就是
2.3 Multipass Compilers
The multipass compiler processes the source code or syntax tree of a program several times. It divided a large program into multiple small programs and process them. It develops multiple intermediate codes. All of these multipass take the output of the previous phase as an input. So it requires less memory. It is also known as ‘Wide Compiler’.
multipass compiler 会多次处理程序的源代码或语法树。它将一个大型程序划分为多个小型程序并进行处理。它开发了多个中间代码。所有这些多通道都将前一阶段的输出作为输入。因此,它需要更少的内存。它也被称为 Wide Compiler。
3. Language processing systems
源代码 (source code) -> 预处理器 (preprocessor) -> 编译器 (compiler) -> 目标代码 (object code) -> 链接器 (Linker) -> 可执行程序 (executables)
Preprocessor: The preprocessor is considered as a part of the Compiler. It is a tool which produces input for Compiler. It deals with macro processing, augmentation, language extension, etc.
预处理器被视为编译器的一部分。它是为编译器生成输入的工具。它处理宏处理,扩充,语言扩展等。
Interpreter: An interpreter is like Compiler which translates high-level language into low-level machine language. The main difference between both is that interpreter reads and transforms code line by line. Compiler reads the entire code at once and creates the machine code.
解释器就像编译器一样,可以将高级语言翻译成低级机器语言。两者之间的主要区别是解释器逐行读取和转换代码。编译器立即读取整个代码并创建机器代码。
Assembler: It translates assembly language code into machine understandable language. The output result of assembler is known as an object file which is a combination of machine instruction as well as the data required to store these instructions in memory.
它将汇编语言代码转换为机器可理解的语言。汇编器的输出结果称为目标文件,该文件是机器指令以及将这些指令存储在内存中所需的数据的组合。
Linker: The linker helps you to link and merge various object files to create an executable file. All these files might have been compiled with separate assemblers. The main task of a linker is to search for called modules in a program and to find out the memory location where all modules are stored.
链接器可帮助您链接和合并各种目标文件以创建可执行文件。所有这些文件可能都已使用单独的汇编器进行了编译。链接器的主要任务是在程序中搜索被调用的模块,并找出所有模块的存储位置。
Loader: The loader is a part of the OS, which performs the tasks of loading executable files into memory and run them. It also calculates the size of a program which creates additional memory space.
加载程序是操作系统的一部分,它执行将可执行文件加载到内存中并运行它们的任务。它还计算程序的大小,该程序将创建额外的内存空间。
Cross-compiler: A cross compiler is a platform which helps you to generate executable code.
交叉编译器是一个可帮助您生成可执行代码的平台。
Source-to-source Compiler: Source to source compiler is a term used when the source code of one programming language is translated into the source of another language.
源到源编译器是将一种编程语言的源代码转换为另一种语言的源时使用的术语。
4. Compiler Construction Tools
These tools use specific language or algorithm for specifying and implementing the component of the compiler.
这些工具使用特定的语言或算法来指定和实现编译器的组件。
Scanner generators: This tool takes regular expressions as input. For example LEX for Unix Operating System.
该工具将正则表达式作为输入。例如,用于 Unix 操作系统的 LEX。
Syntax-directed translation engines: These software tools offer an intermediate code by using the parse tree. It has a goal of associating one or more translations with each node of the parse tree.
这些软件工具通过使用解析树提供中间代码。它的目标是将一个或多个转换与解析树的每个节点相关联。
Parser generators: A parser generator takes a grammar as input and automatically generates source code which can parse streams of characters with the help of a grammar.
解析器生成器将语法作为输入,并自动生成可在语法帮助下解析字符流的源代码。
Automatic code generators: Takes intermediate code and converts them into Machine Language
接受中间代码并将其转换为机器语言。
Data-flow engines: This tool is helpful for code optimization. Here, information is supplied by user and intermediate code is compared to analyze any relation. It is also known as data-flow analysis. It helps you to find out how values are transmitted from one part of the program to another part.
该工具有助于代码优化。在此,信息由用户提供,并且将中间代码进行比较以分析任何关系。也称为数据流分析。它可以帮助您了解如何将值从程序的一个部分传输到另一部分。
intermediate representation,IR:中间表示
front end:前端
back end:后端
References
https://www.guru99.com/compiler-design-tutorial.html
http://personal.kent.edu/~rmuhamma/Compilers/MyCompiler/phase.htm
Compiler - 编译器的更多相关文章
- JSP编译成Servlet(五)JDT Compiler编译器
通过JSP编译器编译后生成了对应的java文件,接下去要把Java文件编译成class文件.对于这部分完全没有必要重新造轮子,常见的优秀编译工具有Eclipse JDT Java编译器和Ant编译器. ...
- 玩转轻巧型C/C++ IDE之C-Free(配置GCC、Visual C++、Borland C++编译器)
玩转轻巧型C/C++ IDE之C-Free(配置GCC.Visual C++.Borland C++编译器) 之前在写一点简单的C/C++代码时习惯了VC++6.0,但是由于在windows7下VC6 ...
- c 编译器大全
c 编译器大全 看了下nginx的auto/cc下的目录,nginx对多种c语言的编辑器都进行了支持.才知道c语言有那么多编辑器. 编译器原理 所谓编译器,就是执行下面的三步骤: 1 将目标语言转换为 ...
- 编译器与Debug的传奇:Grace Murray Hopper小传
摘要: 改变世界的程序员前辈. 来自:http://www.road2stat.com/cn/network_3c/grace_murray_hopper.html 这两天读<UNIX痛恨者手册 ...
- Windows下的Objective-C集成开发环境(IDE)(转)
Objective-C是苹果软件的编程语言,想要上机学习.调试,有一个集成开发环境(IDE)方便很多.有三类方法搭建Objective-C的集成开发环境: 1) 使用苹果的平台,集成开发环境使用X ...
- 75篇关于Tomcat源码和机制的文章
75篇关于Tomcat源码和机制的文章 标签: tomcat源码机制 2016-12-30 16:00 10083人阅读 评论(1) 收藏 举报 分类: tomcat内核(82) 版权声明:本文为 ...
- Java基础常见英语词汇
Java基础常见英语词汇(共70个) ['ɔbdʒekt] ['ɔ:rientid]导向的 ['prəʊɡræmɪŋ]编程 OO: object ...
- IT软件开发常用英语词汇
Aabstract 抽象的abstract base class (ABC)抽象基类abstract class 抽象类abstraction 抽象.抽象物.抽象性access 存取.访问access ...
- SQLite剖析之内核研究
先从全局的角度把握SQLite内核各个模块的设计和功能.SQLite采用了层次化.模块化的设计,而这些使得它的可扩展性和可移植性非常强.而且SQLite的架构与通用DBMS的结构差别不是很大,所以它对 ...
- jquery 中一些 特殊方法 的特殊使用 一览表
cnblogs的页面, 一种是管理页面, 是随笔的列表 a full list of essays. 另一种是 首页. 要搜索文档的话, 就使用 "首页"的那种方式. 一个jque ...
随机推荐
- C#配置系统
读取JSON文件 NuGet两个包:Microsoft.Extensions.Configuration,Mircosoft.Extensions.Configuration.Json. { &quo ...
- 实战案例分享:如何基于Apache SeaTunnel全方位进行高效二次开发
大家好,我是范佳,是Apache SeaTunnel社区的PMC member,同时也是白鲸开源高级开发工程师.今天给大家分享一些基于Apache SeaTunnel二次开发的内容. 这部分内容主要涉 ...
- linux下将qt程序打包成appimage程序
linux下将qt程序打包成appimage程序 一.环境准备 1.1下载linuxdeployqt的程序(打包qt程序的工具) https://github.com/probonopd/linuxd ...
- 【2020.11.20提高组模拟】祖先(ancestor) 题解
[2020.11.20提高组模拟]祖先(ancestor) 题解 题目描述 对于每个\(i\),它都要往前面拜访它的祖先.对于\(i\)之前的编号为\(j\)的节点,如果要拜访的话需要满足对于\(\f ...
- maixpy 常用API整理
2.openmvAPI整理 2.1 cmath - 复数的数学函数 cos cmath.cos(z) 返回z的余弦. exp cmath.exp(z) 返回z的指数. log cmath.log(z) ...
- 数栈技术分享:前端小姐姐和你聊聊IOC中依赖注入那些事 (Dependency inject)
Part1: What is Dependency injection 依赖注入定义为组件之间依赖关系由容器在运行期决定,形象的说即由容器动态的将某个依赖关系注入到组件之中在面向对象编程中,我们经 ...
- [abc313 h/ex] Group Photo
Ex - Group Photo 很牛的题 设\(A_0=A_{n+1}=INF\),那么对于每个\(B_i\)有\(B_i>\min(A_{i-1},A_i)\),所以考虑设\(C_i\)表示 ...
- window10本地搭建DeepSeek R1(一)
本章介绍在window上部署 DeepSeek R1-8B + Open WebUI :需要安装的有:Ollama,python 3.11,DeepSeek ,Open WebUI. 一:环境:我的w ...
- Google Cloud Function函数访问AWS的Redis服务(二)
上一章介绍了使用VP嗯将Google Cloud和AWS的网络连通,这里介绍如何使用:使用Google Cloud Function 访问AWS的Redis服务. 一:Google Cloud 创建 ...
- java学习篇(一)—— CPP和Java的区别之基础概念
一些感想 写在开头,如果你是一个坚定选择工作的研究生,在CPP和Java之间反复跳转,那么有以下几种情况,建议你选CPP: 对CPP有强大的兴趣,且组内有成熟的方向,例如:高性能计算.音频开发等方向, ...