
Compiler Organization
- single pass compilation
o load compiler
o read source code
o output object code
- multi-pass compilation
o loading time for each modules (lexical analysis, syntax analysis, etc.)
o symbol and name tables must be distributed correctly
o compiler administration (error handling, supporting routines)
- environment settings
o default output code name, error message file and source file extension
o environment variable parsing
o argument parsing (getopt())
o getenv() and putenv()
- file manipulations
o FILE *fopen(const char *filename, const char *mode);
§ r or rb
§ Open file for reading.
§
§ w or wb
§ Truncate to zero length or create file for writing.
§
§ a or ab
§ Append; open or create file for writing at end-of-
§ file.
§
§ r+ or rb+ or r+b
§ Open file for update (reading and writing).
§
§ w+ or wb+ or w+b
§ Truncate to zero length or create file for update.
§
§ a+ or ab+ or a+b
§ Append; open or create file for update, writing at
§ end-of-file.
§
o int fclose(FILE *stream);
o int feof(FILE *stream);
- error report (e.g., “Error: line 123 invalid syntax.”)
o Types of errors
§ Ambiguous name: a name is defined two or more times in a block.
§ Invalid comment: a closing comment delimiter is missing.
§ Invalid name kind: a wrong kind of name is used.
§ Invalid numeral: a numeral is overflowed.
§ Invalid index range: array index is out of bound.
§ Invalid syntax: violation of syntactic rules.