2. TYPES OF LANGUAGE PROCESSOR
• 1.) ASSEMBLER
Is a translator program that translates assembly language to machine language.
• 2.) INTERPRETER
A type of language processor that operates one instruction at a time, translating a high-level language statement
and executing immediately.
Generally run more slowly than compiled programs.
• 3.) COMPILER
Is a translator program, which transforms a source program, composed of high-level language statement into an
object program consisting of machine-language executable code.
Structure of Programming Language
3. Compilation Occurs in 2 Broad Phases
1. Decomposes the source program into small identifiable units and analyzes
it for syntactical accuracy.
2. Takes the machine-code modules associated with the basic units identified
in the 1st phase and uses them to compose the object program.
Structure of Programming Language
4. THE COMPILE PROCESS
• SOURCE PROGRAM ANALYSIS
• LEXICAL ANALYSIS
• TOKENS
• SYMBOL TABLES
• SYSNTACTIC ANALYSIS
• PARSE TREE/ SYNTAX TREE
• ERROR HANDLER
• OPTIMIZATION
Structure of Programming Language
5. SOURCE PROGRAM ANALYSIS
• The first phase of the compile process encompasses the lexical analysis and
the syntactic analysis, producing the symbol table and intermediate
(assembly-level) code.
Structure of Programming Language
6. LEXICAL ANALYSIS
• Is concerned with the actual text of the program, which is considered to be a
meaningful sequence of characters.
Structure of Programming Language
7. TOKENS
• Separate pieces of programs.
• Are the basic symbols used by the program: identifiers, operators,
punctuation, language keywords, constants.
Structure of Programming Language
8. SYMBOL TABLES
• Also called the dictionary.
• Map program symbols such as variables with their properties such types, size,
and relative location.
Structure of Programming Language
9. SYNTACTIC ANALYSIS
• Is concerned with identifying the logical structure of the program in
accordance with the rules of grammar governing the high level language.
Structure of Programming Language
10. PARSE TREE/ SYNTAX TREE
• Contains the hierarchy of operations in the high-level language statements.
• Every leaf node contains one of the symbols (tokens) in the statement.
Structure of Programming Language
11. ERROR HANDLER
• During the lexical and syntactical analyses, information regarding an error
encountered is sent to the error handler module of the compiler, which will
arrange to print out a message to the user.
Structure of Programming Language
12. INTERMEDIATE CODE
GENERATION
• The result of the lexical and syntactic analyses and the information in the
symbol table are brought together to produce program code in some
intermediate from similar to assembly- language code.
• Output from the syntactic analysis step, the intermediate code serves as
input to the code generation step.
• Output from the syntactic analysis step the intermediate code serves as
input to the code generation step.
Structure of Programming Language
13. OPTIMIZATION
• To produce efficient code
• To make more efficient use of main storage and processor time
• To correct “ bad programming practice”
• For detecting code that can be moved out of a loop ( to improve the efficiency of
the program, and its logical structure).
• Detection and elimination of dead code
• A DEAD CODE is a program code that is accessible in the normal processing of
the program and will consequently never be executed.
Structure of Programming Language