Compiler - 编译器

intermediate representation,IR:中间表示
front end,FE:前端
middle end,ME:中端
back end,BE:后端

The first compiler was build by John Backum and his group between 1954 and 1957 at IBM.
编译器就是将高级语言翻译为低级语言的程序。

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.

  1. Front end: It maps legal code into Intermediate Representation (IR).
  2. 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.
该工具有助于代码优化。在此,信息由用户提供,并且将中间代码进行比较以分析任何关系。也称为数据流分析。它可以帮助您了解如何将值从程序的一个部分传输到另一部分。

References

https://www.guru99.com/compiler-design-tutorial.html
http://personal.kent.edu/~rmuhamma/Compilers/MyCompiler/phase.htm

Compiler - 编译器相关推荐

  1. JIT Compiler编译器及指令集

    JIT Compiler编译器及指令集 LLVM一些编程语法语义特性 High Level Structure Module Structure LLVM 程序由Module's组成,每个 's 是输 ...

  2. JIT Compiler编译器

    JIT Compiler编译器

  3. 编译器和解释器(Compiler and Interpreter)

    原文地址: juejin.im/post/5cea0c- 在计算机的世界中,一个Programmer多多少少有听说过编辑器,解释器,机器码,字节码这些名词, 现在我们稍微深入问一问: 这些名词分别表示 ...

  4. 【编译原理入门】–编译器compiler

    编译原理[入门]–编译器compiler 参考:https://www.youtube.com/watch?v=cxNlb2GTKIc&list=PLTd6ceoshpreZuklA7RBMu ...

  5. java实现语法分析器_200 行 JS 代码,带你实现代码编译器

    一.前言 对于前端同学来说,编译器可能适合神奇的魔盒 ,表面普通,但常常给我们惊喜. 编译器,顾名思义,用来编译,编译什么呢?当然是编译代码咯 . 其实我们也经常接触到编译器的使用场景: React ...

  6. 如何保证交叉表编译器和目标系统版本一致_嵌入式系统词汇表

    欢迎FPGA工程师加入官方微信技术群 点击蓝字关注我们FPGA之家-中国最好最大的FPGA纯工程师社群 A ASIC(专用集成电路) Application-Specific Integrated C ...

  7. 编译器与Debug的传奇:Grace Murray Hopper小传

    摘要: 改变世界的程序员前辈. 来自:http://www.road2stat.com/cn/network_3c/grace_murray_hopper.html 这两天读<UNIX痛恨者手册 ...

  8. 编译器与Debug的传奇:女牛人Grace Murray Hopper小传

    来自:http://www.road2stat.com/cn/network_3c/grace_murray_hopper.html 这两天读<UNIX痛恨者手册>时看到一句被引用的牛人体 ...

  9. 编译原理——SysY编译器实践报告

    Jason Compiler编译器概述 基本功能 实现将C语言自己SysY分别转换成两种中间表示Eeyore和Tigger,以及最终的Risc-V指令. 使用如下命令生成Eeyore中间表示: ./m ...

最新文章

  1. 深度学习调参tricks总结!
  2. 面试官:Redis 新版本开始引入多线程,你怎么看?
  3. FirstDay@JavaOne2017
  4. java 模块化_Java 9 新特性 - 模块化 - Java 技术驿站-Java 技术驿站
  5. Java中数组的length属性
  6. 为什么要编写单元测试–测试技巧8
  7. 腾讯互娱开源分布式开发框架 Pebble
  8. 多线程,异步委托,同步委托几种方式的区别
  9. ACCESS的Ole对象读取写入
  10. mysql查看和修改密码策略
  11. 取PE文件OriginalFilename-解析VERSION资源
  12. 手机图形计算器matlab,科学图形计算器 Mathlab
  13. VFP基础教程 2.8 使用命令建立和操作索引文件
  14. Android测试工具-Emmagee使用
  15. 深度图像确定目标距离_技术交流一种距离选通水下激光成像系统设计与实验研究...
  16. 【游戏运营】【实战】首充分析——恋与制作人
  17. 客户的sample和项目计划
  18. 小说:凡人修仙路基础
  19. windows网络适配器 黄色下三角
  20. 微信小程序--视频播放器

热门文章

  1. 记录一次渗透测试算命网站
  2. 无法访问计算机请检查名称的拼写,windows无法访问 请检查名称的拼写… 错误代码:0x80004005和0x80070035和 0x800704cf...
  3. php无闪动刷新,简单的无闪动刷新页面/部分内容
  4. C#,彩票数学——什么是彩票缩水的数学概念与原理?有什么具体算法?如何在不增加投入金额的情况下保证中奖率?
  5. git 下载代码到本地
  6. Python之父抛弃Python!现在学Python还有用吗?
  7. Android 形状绘制 —— shape详解
  8. Beyond Compare中文乱码怎么办
  9. 程序员的机器学习入门笔记(一):基本概念介绍
  10. VectorMapNet | 端到端的矢量化高精地图学习