ConpSci - Program Construction Flashcards
(13 cards)
Compilation Process - Lexical Analysis
Comments and whitespace are removed
Keywords, variables and constants are replaced by tokens
A symbol table containing the addresses of variables, labels and subroutines
Compilation Process - Syntax Analysis
Tokens are checked against syntax rules of the language, if syntax errors are found, error messages are produced
Compilation Process - Semantic Analysis
Variables are checked to ensure they are correctly declared, used and correct data type declared for each. (Static Semantic)
Operations are checked to ensure they are valid (quotient not stored as integer)
Compilation
Compilation only needs to occur once
Can be used by any device without any extra software
Hardware dependent
Faster
Intellectual property protected
Interpretation
Debugging is easier
Must be interpreted on every execution
Not hardware dependent
An interpreter is needed to run
Slower
Assembly
One-to-one translation from assembly (low level code) to machine code.
Using assembly provides more control over memory and storage
Less processing required to run
Difficult to learn and complex programs
Syntax Error
Occurs when an instruction doesn’t follow the expected syntax of the language
Print() (case sensitive)
Execution Error
Occurs when the program is running
More memory requested than available
Logical Error
Occurs when the program outputs an incorrect answer.
Negative result for age
Linking Error
Occurs when a program calls a library that hasn’t been linked.
sqrt() being called without the appropriate library
Rounding Error
Occurs when a number is approximated to a nearest order.
Truncation Error
Occurs when a number is approximated to an order by cutting off.
Error Types
Logic / Semantic
Memory
Linking
Syntax
Rounding
Truncation