unit 2
unit 2
□ Language processing activities arise due to the difference between the manner
in which a software designer describes ideas concerning the behavior of a
software and the manner in which these ideas are implemented in a computer
system.
Some definitions…
▪ Semantic: It represents the rules of the meaning of the domain.
▪ Semantic gap: It represents the difference between the semantic of
two domains.
▪ Application domain: The designer expresses the ideas in terms related
to application domain of the software.
▪ Execution domain: To implement the ideas of designer, their description has
to be interpreted in terms related to the execution domain of computer
system.
Consequences of Semantic Gap
• Source language: The program which forms the input to a language processor is
a source program. The language in which the source program is written is
known source language.
Errors
Synthesis phase
• synthesis phase is concerned with the construction of target language.
• Itincludes mainly two activitiesmemory allocation and code generation.
(Back end)
Phases of language Processor
Phases of language Processor
Phases of language Processor
Phases of language Processor
Phases of language Processor
Pass of Language Processor
❖ A Language Processor Pass is processing of every statement in the
source program to perform a Language Processing Activities.
□ Pass I
– Perform analysis of the source program and note relevant information.
– The first pass performs analysis of the source program and reflects its
results in the intermediate representation.
□ Pass II
– Perform synthesis of target program.
– The second pass reads and analyzes the intermediate representation
to perform synthesis of the target program.
Pass of Language Processor
Pass of Language Processor
Two-pass schematic of language
processor
Source Front Back Target
Program
Program End End
Intermediate
representation
(IR)
Intermediate representation (IR)
• An intermediate representation is a representation of a source program
which reflects the effect of some, but not all analysis and synthesis functions
performed during language processing.
• An IR properties,
– Ease of use
– Processing efficiency
– Memory efficiency
Front end of Language Processor
• IR contains
1. Intermediate Code (which is the description of the source program).
2. Tables –Symbol Table
Symbol Table
Intermediate representation (IR)
Memory Allocation and Code Generation
Memory Allocation
▪ The back end computes the memory requirement of a variable from its
type, length and dimensionality information found in the symbol table and
allocates memory to it.
▪ The address of the allocated memory area is entered in the symbol table.
Code Generation
▪ Two key decisions involved in generating good quality target code are:
1. What instructions should be used for each of the
actions in the intermediate code?
2. Which CPU registers should be used for evaluating expressions ?
Back end of Language Processor