1. 3 Analysis And Synthesis OF LP • Language Processor = Analysis of Source Program + Synthesis of Target Program. 1
Analysis And Synthesis OF LP • We refer to the collection of language processor components engaged in analyzing a source program as analysis phase of the LP. • Components engaged in synthesizing a target program constitute the synthesis phase. 2
1. Analysis of Source Program • A specification of the source language forms the basis of source program analysis. The specification consist of three components. 3
1. 1 Lexical Analyzer • Lexical rule which governs the formation of valid lexical units in the source language. • For example, it generates the token from syntax. 4
1. 2 Syntax Analyzer • Syntax rule which govern the formation of valid statements in the source language. • For example, it find any syntax error like ; missing. 5
1. 3 Semantic Analyzer • Semantic rules which associate meaning with valid statements of the language. • For example, the syntax “I saw child with telescope” has more then one meaning, but which one is valid. 6
2. Synthesis of Target Program • The synthesis phase is concerned with the construction of target language statements which have the same meaning as a source statement. • Typically this consist of two main activities: – Creation of data structure in the target program. – Generation of target code. • We refer to these activities as memory allocation and code generation activity. 7