3.8 Program Construction Flashcards

1
Q

a

Translators

A

convert one language to another, usually high level to machine code (e.g compilers, interpreters)

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

Assemblers

A

Translates assembly code into machine code, 1:1 relationship so relatively simple translation process and faster execution due to this close relationship. Comments get removed and symbolic references get replaced for addresses Non portbale (assembly is artichtecture specific, like interpreters)

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

Compiler

A

Translates code into executeable form but does not execute the program. Takes a while to compile however faster execution as its precompiled. If a syntax error occurs the the program halts and the error is reported. If its a semantic error then it waits until the end to produce an error message. Produces in the form of an excurtable file so its easy to transfer, also in unredable format so secure. Compillers produce machine code specific to computer architecture.

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

Interpreters

A

Translates and execute source code line by line. Uses bytecode to** speed up translation process** . Runtime errors crash the program, synatx makes it halt and report the error. Its easier debugging since errors are reported as they occur.

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

Lexical Analysis

A
  • Whitespaces and comments are removed
  • Tokenisation occurs which converst part of code into tokens
  • A symbol table is created to keep track of identfiers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Syntax Analysis

A
  • Tokens are identified to see if they match the syntax of the language used and are in the correct order. BNF would be used to define grammatical rules. If an error is found, program is halted and error is reported.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Semantic Analysis

A

Compiler checks meaning of the program

Type Checking - using incorrect data types (e.g int age = “hello”)

Scope resolutions - checke to see if global/local variables used correctly

Logic Error - cheks that varaibles are intiallised, for infinite loops and unreachable code.

For semantic errors, the code continues and error are displayed at the end.

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

Code Generation

A

Object code is created - Executable file

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

Code Optimisation

A

Idenitfy redudundant code and rectify it.

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