Home>Article> Explain what the program is

Explain what the program is

青灯夜游
青灯夜游 Original
2021-03-24 14:48:10 12782browse

The interpreter is a language processing program that can directly execute the source program or the internal form of the source program (intermediate code) when running a user program. The advantages of the interpreter program are: simple structure, easy to implement, easy program scheduling and modification, human-computer dialogue, and suitable for programming and execution in interactive conversation mode.

Explain what the program is

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

The interpreter is a language processing program that works basically the same as the compiler in terms of lexical, syntactic and semantic analysis, but when running a user program, it directly executes the source program or the internal form of the source program (intermediate code). Therefore, the interpreter does not generate the target program, which is the main difference between it and the compiler.

The interpreter program consists of a master control program and several execution subroutines. The working process of the interpreter program is as follows: First, the master control program performs initial preparation work and sets the initial state of the work; then, a statement S is taken from the source program and a syntax check is performed. If there is an error in the syntax, an error message will be output; otherwise, the corresponding execution subroutine will be executed according to the determined statement type. After returning, check whether the interpretation work is completed. If it is not completed, continue to interpret the next statement; otherwise, perform necessary aftermath work.

The working process of the explanation program is as follows:

①The initialization work is completed by the master control program.

② Take out a statement from the source program in sequence and perform a syntax check. If there is an error, an error message will be output; if the syntax check passes, the statement will be converted into a corresponding instruction and executed.

③ Check whether the source program has been fully interpreted and executed. If not, continue to interpret and execute the next statement until all statements have been processed.

Features:

The working method of the interpreter is very suitable for people to talk to the computer through the terminal device. For example, if you type a command or statement on the terminal, the interpreter will start immediately. This statement is interpreted into one or several instructions and submitted to the hardware for immediate execution and the execution results are reflected to the terminal. After typing the command from the terminal, the calculation results can be obtained immediately.

This is indeed very convenient and is very suitable for some minicomputer computing problems. However, the execution speed of the interpreter is very slow. For example, if a loop occurs in the source program, the interpreter will repeatedly interpret and submit this set of statements for execution, which causes a lot of waste.

A high-level language program that interprets and translates the source program into machine code and executes it at the same time. Therefore, the function of the interpreter is: interpret and execute high-level language programs. Due to its convenience and good interactivity, some early high-level languages adopted this method, such as BASIC and dBASE. But its weakness is low operating efficiency. The running of the program depends on the development environment and cannot be run directly under the operating system.

The outstanding advantage of the interpreter is that it can be implemented simply, and it is easy to flexibly and conveniently insert modifications and debugging measures during the interpretation and execution process. However, the biggest disadvantage is that the execution efficiency is very low. For example, a statement that needs to be executed multiple times only needs to be translated once when using a compiler; but it needs to be translated and executed repeatedly in an interpreter.

For more programming related knowledge, please visit:Programming Video! !

The above is the detailed content of Explain what the program is. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn