Program construction #8 Flashcards

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

what are assemblers

A

Program which converts the low-level assembly programming language into machine code. done by converting the one-word assembly instructions into an opcode, e.g. converting AND to 0010. it also allocates memory to variables, often resulting in an operand.

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

what are interpreters

A

Code is converted by an interpreter before high level programming languages can be run. one line at a time, into machine code, which is then executed by the CPU.

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

what are compilers

A

used when high level programming languages are converted into machine code, ready to be executed by the CPU. There are four main stages of compilation

-lexical analysis
-syntax analysis
-semantic analysis
-code generation

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

What are the 4 main stages of compilation ?

A
  • Lexical analysis
  • Syntax analysis
  • Semantic analysis
  • Code generation

ofc i repeated this dnc

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

what is lexical analysis (stage of compilation)

A

-comments and unneeded spaces are removed
-keywords, constants and identifiers are replaced by ‘tokens’
-a symbol table is created which holds the addresses of variables, labels and subroutines

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

what is syntax analysis (stage of compilation)

A

-tokens are checked to see if they match the spelling and grammar expected, using standard language definitions, this is done by parsing each token to determine if it uses the correct syntax for the programming language.
-if syntax errors are found, error messages are produced

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

what is semantic analysis (stage of compilation)

A

-variables are checked to ensure they have been properly declared and used
-variables are checked to ensure they are of the correct data type, e.g. real values are not being assigned to integers
-operations are checked to ensure they are legal for the type of variable being used, e.g. you would not try to store the result of a division operation as an integer

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

what is code generation (stage of compilation)

A

-machine code is generated
-code optimisation may be employed to make it more efficient/faster/less recourse intense

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

what are examples of 6 programming errors

A

-syntax
-logical
-linking
-rounding
-truncation
-runtime/execution

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

what is a syntax error

A

occurs when command doesnt follow expected syntax of the language, e.g. when a keyword is incorrectly spelt

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

what is runtime/execution error

A

only occurs when program is running and is difficult to foresee before a program is compiled and run

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

what is logical error

A

causes program to output an incorrect answer, e.g. an algorithm that calculates a perrons age from their date of birth but ends up giving negative numbers.

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

what is a linking error

A

occurs when programmer calls a function within a program and the correct library has not been linked to that program

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

what is rounding error

A

when number is approximated to nearest whole number/tenth/hundredth, etc.

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

what is truncation error

A

when a number is approximated to a whole number/tenth/hundredth, etc. nearer zero.

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