这个编译器图不准确吗?
Is this diagram of a compiler inaccurate?
我正在阅读我的教科书,我看到了这个编译器图:
这不准确吗?汇编代码是在哪里产生的?上面说编译器的输出是机器码,但我以为编译器的输出是汇编代码?
一点也不——编译器是一个非常模糊的术语(词源见 this answer)。正如 user207421 所提到的,有些编译器可以生成目标代码、可解释的字节码和程序集。
但是,有些编译器也可以生成其他高级语言,即它们可以有效地将代码从一种高级语言转换为另一种高级语言(参见 transcompilers). There are also compilers that convert code from low-level languages (once again, it can be object code, byte-code or assembly) to high-level languages (see decompilers). Then there are compilers which generate code to run on other CPU architectures than the one on which they are running (see cross-compiler). Furthermore, there are also compilers that produce other compilers (the so called compiler-compilers)- 这些编译器采用某种形式的语言描述,并且为该语言生成编译器。
如果您想了解更多信息,page 是一个很好的起点。
实现编译器的方法有很多种。
您的图表显示了一个示例,在其他情况下编译器与您显示的图表不匹配。
我正在阅读我的教科书,我看到了这个编译器图:
这不准确吗?汇编代码是在哪里产生的?上面说编译器的输出是机器码,但我以为编译器的输出是汇编代码?
一点也不——编译器是一个非常模糊的术语(词源见 this answer)。正如 user207421 所提到的,有些编译器可以生成目标代码、可解释的字节码和程序集。
但是,有些编译器也可以生成其他高级语言,即它们可以有效地将代码从一种高级语言转换为另一种高级语言(参见 transcompilers). There are also compilers that convert code from low-level languages (once again, it can be object code, byte-code or assembly) to high-level languages (see decompilers). Then there are compilers which generate code to run on other CPU architectures than the one on which they are running (see cross-compiler). Furthermore, there are also compilers that produce other compilers (the so called compiler-compilers)- 这些编译器采用某种形式的语言描述,并且为该语言生成编译器。
如果您想了解更多信息,page 是一个很好的起点。
实现编译器的方法有很多种。
您的图表显示了一个示例,在其他情况下编译器与您显示的图表不匹配。