interpreter
compiler
stages of compilation
translators
compiler
interpreter
assembler
lexical analysis
first stage in compilation
- all unnecessary characters eg white space/ comments are removed
- program is converted into tokens - tokenisation
- variables and constants are also added to a symbol table
keyword table
tokenisation
in lexical analysis to convert the program into tokens
- a key word table is used that contains all tokens for words/ symbols in a programing lang
syntax analysis
parsing
checking the tokenised list for errors using grammatical rules for the programming lang
lexeme
each meaningful character or collection of characters
may be used as an identifier or may be a key word
- in lexical analysis the whitespace and comments are removed and each lexeme is identified before categorising each lexeme to tokenise it
code generation
produces object code to perform the task defined by the source code
- must be syntactically correct to produce obj code
- in machine code (binary)
- either in executable machine code or an intermediate form (converted to MC when program is loaded)
benefits of intermediate code (code generation)
supports
- use of relocatable code so program can be stored anywhere in main memory
- addition of library routines to minimise storage size
- linking of programs to run together
optimisation
bootstrap
when comp is switched on
BIOS starts off bootstrap
flash memory
used as main memory on phones - explains why their start up is so fast
2 parts
- OS - read only - can be updated by manufacturers but user cant access
- apps (+ data) - user cant access
resource management
split into 3 areas: CPU, memory, I/O system
- involves scheduling to allow for better utilisation of time and resources
- for I/O operations deals with: I/O operations that have been initiated, I/O operations that occur wile software is run and resources are requested
direct memory access controller (DMA)
kernel
how the OS hides the complexity of hardware from users
syntax diagrams
Backus Naur form (BNF)
BNF notation symbols
<> encloses an item
::= separates an item from its definition ‘is defined as’
; end of a rule
eg <variable> ::= <letter> | <digit>;</digit></letter></variable>
<letter> ::= A | B | C;
<digit> ::= 1 | 2 | 3;
a vairbale consisting of any number of letters or digits could be defined as
<variable> ::= <Letter>|<variable><Letter>|<variable><Digit>
| between items indicates a choice
</Digit></variable></Letter></variable></Letter></variable></digit></letter>
Reverse Polish notation (RPN)