登录

Language Translators

Translation and execution of programs

  • Instructions in a program can only be executed when written in machine code and loaded into the main memory of a computer.

    • Assembler

    • Compiler

    • Interpreter

  • Programming instructions written in any programming language other than machine code must be translated before they can be used.

  • The systems software used to translate a source program written in any language other than machine code are translators.

  • There are three types of translator available, each translator performs a different role.

Assemblers

  • Programs written in assembly language are translated into machine code by an assembler program.

Compilers and interpreters

  • Programs written in a high-level language can be either translated into machine code by a compiler program, or directly executed line-by-line using an interpreter program.

Assembler

Compiler

Interpreter

Source program written in

assembly language

high-level language

high-level language

Machine dependent

yes

no

no

Object program generated

yes, stored on disk or in main memory

yes, stored on disk or in main memory

no, instructions are executed under the control of the interpreter

Each line of the source program generates

one machine code instruction, one to one translation

many machine code instructions, instruction explosion

many machine code instructions, instruction explosion


Partial compiling and interpreting

  • In order to achieve shorter execution times, many high-level languages programs use a system that is partially compilation and partially interpretation.

  • The source code is checked and translated by a compiler into object code.

  • The compiled object code is a low-level machine independent code, called intermediate code, p-code or bytecode.

Tip

Source code:

print("Hello World")

Bytecode:

1 0 LOAD NAME
2 LOAD CONST
(print)
0 (Hello World')
4 CALL FUNCTION1 (1 positional,  keyword pair)
6 RETURNVALUE

Translator
多选题
ID:137

The translator that can translate language as machine dependent:

[0/1]

Translator
多选题
ID:138

The translator that generate object program(executable file):

[0/2]

Translator
多选题
ID:139

The translator that translate language with one line to many lines machine code:

[0/2]

Translator
单选题
ID:140

The translator that finds all errors in a program

[0/1]

Translator
单选题
ID:141

The translator that is easier to develop and debug a program

[0/1]

IDE
填空题
ID:142

An (IDE) is used by programmers to aid the writing and development of programs.

[0/1]

Integrated development environment (IDE)

  • An integrated development environment (IDE) is used by programmers to aid the writing and development of programs.

  • IDEs usually have

  • a source code editor

  • a compiler, an interpreter, or both

  • a run-time environment with a debugger

  • an auto-documenter

Features

  • coding

    • context-sensitive prompts

  • initial error detection

    • dynamic syntax checks

  • presentation

    • prettyprint

    • expandand collapse code blocks

  • debugging

    • single stepping

    • breakpoints

    • report window

Source code editor

  • A source code editor allows a program to be written and edited without the need to use a separate text editor.

  • Most source code editors colour code the words in the program and layout the program in a meaningful way (prettyprinting).

Compiler, an interpreter, or both

  • Most IDEs usually provide a compiler and/or an interpreter to run the program. The interpreter is often used for developing the program and the compiler to produce the final version of the object code.

Run-time environment with a debugger

  • A debugger is a program that runs the program under development and aids the process of debugging.

  • It allows the programmer to single step through the program a line at a time (single stepping) or to set a breakpoint to stop the execution of the program at a certain point in the source code.

  • A report window then shows the contents of the variables and expressions evaluated at that point in the program.

  • This allows the programmer to see if there are any logic errors in the program and check that the program works as intended.

Auto-documenter

  • Most IDEs usually provide an auto-documenter to explain the function and purpose of programming code.

IDE
多选题
ID:143

An IDE usually have:

[0/2]

登录