编译时会发生什么? [英] What happens when I compile?

查看:343
本文介绍了编译时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道什么是编译,当你编译时会发生什么?我的意思是你按下编译或在控制台中输入,但它实际上是在背景中做什么?

I wonder what is compiling, what happens when you compile? I mean yes you press compile or type in in the console but what does it actually do in the "background"?

推荐答案


  1. 首先,编译器lexes源代码。这意味着它将源转换为一系列令牌。令牌是对编译器有意义的字母,数字和符号序列。

  1. First, the compiler "lexes" the source. This means that it transforms the source into a sequence of "tokens." Tokens are sequences of letters, numbers and symbols that have meaning to the compiler.

接下来,编译器解析来自第一步的令牌序列。这意味着编译器会检查以确保源符合规则(语法)的编程语言。

Next, the compiler "parses" the sequence of tokens from step one. This means that the compiler checks to ensure that the source conforms to rules (the grammar) of the programming language.

接下来,编译器执行句法分析来创建源的表示,以确定源的语义含义。这是编译器将构建语法树的步骤。

Next, the compiler performs syntactic analysis to create a representation of the source to determine the semantical meaning of the source. This is the step where the compiler will build a syntax tree.

最后,编译器将生成输出,捕获源在目标表示中的语义含义(无论是机器码,中间语言如 Microsoft CIL 或其他编程语言)。

Finally, the compiler will generate output that captures the semantic meaning of the source in the target representation (be it machine code, an intermediate language such as Microsoft's CIL, or another programming language).

http://en.wikipedia.org/wiki/Compiler =nofollow noreferrer> Wikipedia 。有关详细信息,请参阅龙书(计算机科学的每个学生都应该学习本书)。

For the brief details see Wikipedia. For the gory details see the dragon book (every student of computer science should study this book).

这篇关于编译时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆