Compilers | ||
The process of compilation can be split into five stages :
Lexical Analysis
|
||
Syntax Analysis This is the process of determining whether the sequence of input characters, symbols, items or tokens obey the rules of the syntax of the language. Parsing is the task of systematically applying the rules to each statement in the program to determine whether it is valid. The syntax analyser will report syntax errors if they occur.
|
||
Semantic analysis is the process of checking the meaning of a program. The compiler decides how the program is to be executed. Eg - In what order to evaluate an arithmetic expression.
|
||
Code Generation. The object code is generated. Most high level language statements will be translated into a number of machine code instructions. A Link editor is a program that would make sure that previously compiled code sections from a library are loaded into the program at compile-time and required links created. The code sections become part of the executable object code. A Linking loader would do a similar task when a program is loaded into memory. These library routines would also be loaded and links made to them.
|
||
Code optimisation techniques attempt to reduce the execution time of the object program by, for example, spotting redundant instructions and producing object code which achieves the same net effect as that specified by the source program but not by the same means. Run-time support routines would also need to be incorporated. These would perform such tasks as run-time error reporting, array element accessing, managing a run-time stack or storage of dynamic data structures.
|
||