Chapter 10 - Programming Language Translators (1.2) Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a Translator?

A

A program that converts high level source code into low level object code so that it can be executed by a computer, input is source code and output is object code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 3 types of Translator?

A
  1. Compiler
  2. Interpreter
  3. Assembler
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Compiler?

A

Program that translates high level code into machine code all at once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are some advantages of a Compiler? (3)

A
  1. Can be run without a translator
  2. Object code is more secure
  3. Don’t need to compile it when you want to run object code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are some disadvantages of a Compiler? (3)

A
  1. Longer than using an Assembler or Interpreter
  2. If changes need to be made then the whole program needs to be compiled again
  3. Can only be executed on certain devices (specific to a certain processor and OS)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When is a Compiler used? (2)

A
  1. When a program needs to be run regularly with occasional change
  2. When the object code produced is going to be sold to users
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an Interpreter?

A

Program that translates high level code into machine code line-by-line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are some advantages of an Interpreter? (2)

A
  1. Stops whenever it detects an error, making it useful for debugging
  2. More portable as code can be executed on a range of platforms
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are some disadvantages of an Interpreter? (2)

A
  1. Requires an interpreter to run on different devices
  2. Code must be translated with an interpreter every time it’s executed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When is an Interpreter used?

A

When you need to test sections of code to check for any errors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Assembly code?

A

Low level language where each instruction translates to one machine code instruction, it’s platform specific

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an Assembler?

A

Translates assembly code to intermediate code (bytecode) so that it can be executed as machine code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the 4 stages of compilation?

A
  1. Lexical Analysis
  2. Syntax Analysis
  3. Code Generation
  4. Optimisation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is Lexical Analysis?

A

Removes unnecessary spaces and comments and performs simple error checking, keywords, variables, and constants are replaced with tokens, information about token associated with each
keyword or identifier is stored in a symbol table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is Syntax Analysis?

A

Tokens analysed against the grammar and rules of the programming language, any that break the rules are flagged up as syntax errors and added to a list of errors, abstract syntax tree is then created (representation of source code)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is Code Generation?

A

Abstract syntax tree used to produce machine code

17
Q

What is Optimisation?

A

Searches through the code to make it more efficient so that it’s faster to execute

18
Q

What is a Static Linker?

A

Piece of software that is responsible for linking external modules and libraries included within the code, in a static linker, modules and libraries are added directly to the main file which increases its size and any external updates to modules and libraries don’t effect the program

19
Q

What is a Dynamic Linker?

A

Piece of software that is responsible for linking external modules and libraries included within the code, in a dynamic linker, addresses of modules and libraries are added to the file where they’re referenced so that when the program is run, the loader retrieves the program at the specified address so that it’s executed, files remain small and external updates can go to the main file

20
Q

What is a Loader?

A

Retrieves the library/sub-routine from the given memory location

21
Q

What are Libraries used for?

A

They provide a specialised range of functions which would usually take alot of time and effort to develop

22
Q

What is a Library?

A

Pre-compiled programs which can be used within other programs using static or dynamic linking, they’re ready to use, error free and can be reused within multiple programs