6, 7, 8. Programs Flashcards
What happens in syntax analysis (2)
- Each statement is checked against the assembler’s rules of syntax
- Parsing happens
What is parsing
Systematically breaking down tokens(/statements) into their (grammatical/syntax) component parts e.g. variable to check their syntax is correct
What happens in semantic analysis (3)
- Variables are checked to ensure they are the correct data type
- Variables are checked to ensure they’ve been properly declared
- Operations are checked that they are legal for the data type used (you can’t divide a string)
What is optimisation
Attempting to reduce the program’s execution time
Linking error definition
When a function/library can’t be found
Run-time error definition
Occurs when program is run - program is asked to do something it can’t, making it crash (e.g. saving something in a file that hasn’t been created)
Interpreter definition
A program that analyses the source code line by line and converts it into machine code (line by line)
Can the program run without the interpreter (when it’s being used)?
The program can only run if the interpreter is present
Interpreter advantages
✅allows for easier program development - errors can be corrected as program is interpreted
✅lines of code can be modified as its run
5 stages of compilation
1 lexical analysis
2 syntax analysis
3 semantic analysis
4 code generation
5 optimisation
What happens in lexical analysis (3)
➡️ all comments and spaces are removed
➡️all keywords, Constants and identifiers are replaced by tokens
➡️a symbol table is created with holds the addresses of variables, labels and subroutines
Assembler definition
A program that converts low-level language programs (e.g assembly language) into executable code
How does an assembler work
Each mnemonic is replaced by the corresponding binary machine code instruction
Compiler definition
A program that translates a complete program written in a high level language (source code) into machine code in one go
How does a compiler work (3)
Each high level language instruction is converted into many low level ones
The compiled program can be loaded into memory and can run independently from the compiler
List of errors produced at the end
Advantages of a compiler
Compiled program runs faster than interpreted program. It checks all lines of code not just the ones being executed
Trace role
Displays order in which line of a program are executed and the values of variables as the program is running
Break point role
Interrupts a program at a specific line allowing programmer to check a variables current value against expected value
Variable watch role
Displays current value of any variable
Single stepping
Allows code to be executed line-by-line, the programmer deciding when to move on so they can examine the program carefully as its run
Memory inspector
Displays contents of a specific section of memory
Error diagnostics role
Displays error messages- helps programmer understand what’s wrong
IDE definition
Integrated development environment
Software to help with software engineering by providing tools to do so
Editor role
Allows programmer to enter and edit source code and design an interface