Next: Additional components: preprocessors, assemblers, loaders/link-editors
Up: Compilers
Previous: The synthesis phases
Any large software is easier to understand and implement
if it is divided into well-defined modules.
Figure 6:
The structure of a compiler.
|
- In a compiler,
- linear analysis
- is called LEXICAL ANALYSIS or SCANNING and
- is performed by the LEXICAL ANALYZER or LEXER,
- hierarchical analysis
- is called SYNTAX ANALYSIS or PARSING and
- is performed by the SYNTAX ANALYZER or PARSER.
- During the analysis, the compiler manages a SYMBOL TABLE by
- recording the identifiers of the source program
- collecting information (called ATTRIBUTES) about them:
storage allocation, type, scope, and (for functions)
signature.
- When the identifier x is found by the lexical analyzer
- generates the token id
- enters the lexeme x in the symbol-table (if it is not already there)
- associates to the generated token a pointer to the symbol-table entry x.
This pointer is called the LEXICAL VALUE of the token.
- During the analysis or synthesis, the compiler may DETECT ERRORS
and report on them.
- However, after detecting an error, the compilation
should proceed allowing further errors to be detected.
- The syntax and semantic phases usually handle a large fraction
of the errors detectable by the compiler.
Next: Additional components: preprocessors, assemblers, loaders/link-editors
Up: Compilers
Previous: The synthesis phases
Marc Moreno Maza
2004-12-02