Translators Flashcards

1
Q

What is a translator?

A

A translator changes a program written in one language into another language (usually machine code)

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

What is an assembler?

A

An assembler converts low level assembly language into machine code.

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

What is an Interpreter?

A

An interpreter converts high-level language one line at a time into machine code and executes it.

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

What is a Compiler?

A

A compiler converts high-level language into machine code for execution at a later time. The entire program is converted at once.

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

Differences between an interpreter and a compiler?

A

Execution Speed -
- An interpreter is slower than a compiler because the code must be reinterpreted each time the program is run
- Compliers can produce much more efficient code than interpreters making the compiled programs runs faster.

Complexity -
- Interpreters are smaller, simpler programs
- Compliers tend to be large complex programs

Error Reporting -
- In error reporting, the interpreter would encounter the errors and report it to the user immediately and stops the program from running.
- The compiler would analyse the entire program, taking note of where errors have occurred and record them in an error file.

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

What is Lexical Analysis?

A
  • Spaces and comments are removed from the code
  • Identifiers, keywords and operators are replaced by tokens. A token is similar to a variable with a name and a value.
  • A symbol table is created. This table stores the addresses of all variables, labels and subroutines used in the program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Syntax Analysis?

A
  • The tokens created in the first stage are checked to see if they follow the syntax rules of the programming language (parsing).
  • During parsing, if a syntax error is found then an error message is displayed and compilation stops.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Semantic Analysis

A
  • Variable checks ensure they are correctly declared and use a valid data type.
  • Operation checks ensure they are correct for the data type.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Code Generation

A

The machine code is generated.

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

Code optimisation

A

The code is optimised so it is fast, efficient and uses a little of the computer’s resources as possible

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