Compiler Principles Chapter One Homework

Compiler Principles Chapter One Homework

1. Compiler Try to teach the program of translating high-level language programs into equivalent machine language programs

2. The purpose of dividing the compilation process into several passes is to make the structure of the compiler clearer

3. To build a compiler program should be mastered: target language, source program, compilation method

4. The vast majority of Shi Jian spent compiling programs on-top: form management

5. The compiler is right: high-level language translation

Questions and answers:
What are the ways for computers to execute programs written in high-level languages, and what are the main differences between them?
There are two main ways for a computer to execute a program written in a high-level language: interpretation and compilation.
In the interpretation mode, the translation program does not use the method of translating the high-level language program into a machine code program in advance, and then executes the machine code program. Every time a source program statement is read, it is translated into a machine code statement string corresponding to its function and executed, and then the next source program statement is read in and interpreted and executed, and the translated machine code statement string is executed in this statement It is not retained afterwards. This method is translated sentence by sentence according to the dynamic execution order of the sentences in the source program. If a sentence is in a loop body, every time the loop is executed to the sentence, it must be translated into machine code before execution.
In the recompilation mode, the execution of the high-level language program is carried out in two steps; the first step is to translate all the high-level language program into a machine code program, and the second step is to execute the machine code program. Therefore, the process of compiling the source program is to first translate and then execute.
From the perspective of execution speed, the compiled high-level language is faster than the interpreted high-level language, but the human interface in the interpreted mode is better than the compiled one, which is convenient for program debugging
. The main difference between the two approaches is that no object code is generated in the interpreted mode. Program, and the object code program is generated in the compilation mode.

As the chief designer of a compiler, you must first have a deep understanding of the syntax and semantics of the source language being compiled, and second, you must fully grasp the function and characteristics of the target instruction. If the target language is a machine instruction, you must also understand the hardware of the machine. The structure and the function of the operating system. Third, the compilation method and the software tools used must also be accurate
. The chief designer must evaluate the requirements of the system function, hardware equipment and software tools when designing the compilation program. The influence of compiler construction.

Guess you like

Origin blog.csdn.net/weixin_44522477/article/details/112062633