# 编译器

> [编译器](https://en.wikipedia.org/wiki/Compiler)：将用编程语言(源语言)编写的计算机代码翻译成另一种语言(目标语言)的计算机程序。

编译程序以高级程序源代码作为输入，以汇编语言或机器语言表示的目标程序作为输出。目标程序会在机器上运行，得到所需的结果。编译器可能执行以下操作：预处理、词法分析、语法分析、语义分析、中间代码生成、代码优化和目标代码生成。

![图1.编译器执行步骤](/files/w8hlqAew5PivhQqfBEq7)

编译器前端和中端理论知识与代码可视化的实现最为相关，后端部分和目标机器代码、特定机器架构相关一般很少用到可视化中。后续两个章节将讲解前端和中端相关的知识并附带小练习，能够帮助大家快速的熟悉核心概念，并对编译器的工作流程有进一步的理解。

### 编译器的工作步骤

![图2.编译器工作步骤](/files/r9ehF3XYOvWtrYvN70D3)

### 扩展阅读

* 书籍：《[龙书](https://book.douban.com/subject/3296317/)》、《[虎书](https://book.douban.com/subject/1806974/)》、《[鲸书](https://book.douban.com/subject/1400374/)》
* [CS143](https://web.stanford.edu/class/cs143/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://code-visualization.shawnxie.top/yuan-li-pian/compiler.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
