KEMBAR78
Fundamentals of Language Processing | PPTX
Fundamentals of Language Processing
 Language Processing = Analysis of SP + Synthesis of TP
 Collection of Language Processing components engaged in
analysis a source program as the analysis phase and
components engaged in synthesizing a target program
constitute the synthesis phase.
Analysis Phase
 The specification consists of three components:
1. Lexical rules which govern the formation of valid
lexical units in the source language.
2. Syntax rules which govern the formation of valid
statements in the source language.
3. Semantic rules which associate meaning with valid
statements of the language.
Analysis Phase
 Consider the following example:
percent_profit = (profit * 100) / cost_price
 Lexical units identifies =, * and / operators, 100 as constant, and
the remaining strings as identifiers.
 Syntax analysis identifies the statement as an assignment
statement with percent_profit as the left hand side and (profit *
100) / cost_price as the expression on the right hand side.
 Semantic analysis determines the meaning of the statement to
be the assignment of profit * 100 / cost_price to percent_profit.
Synthesis Phase
 The synthesis phase is concerned with the construction of
target language statements which have the same meaning as
a source statement.
 It performs two main activities:
1. Creation of data structures in the target program
(memory allocation)
2. Generation of target code (code generation)
Phases & Passes of LP
Language Processor
 Analysis of source statements can not be immediately followed by
synthesis of equivalent target statements due to following reasons:
1. Forward References
2. Issues concerning memory requirements and organization of a LP
Analysis
Phase
Synthesis
Phase
Source
Program
Target
Program
ErrorsErrors
Forward Reference
 It is a reference to the entity which precedes its
definition in the program. Using a variable before a value is
assigned to it is called a forward reference.
 Forward referenced variables have the scope of the
location where they are first referenced. They cannot be
read before a value has been assigned to them, but they
can be used for further forward reference.
Language Processor Pass
 Pass I : performs analysis of Sorce Program and notes
relevant information.
 Pass II : performs synthesis of target program.
Pass I analysis Source Program and generates IR which is
given as input to Pass II to generate target code.
Intermediate Representation (IR)
 An IR reflects the effect of some but not all, analysis
and synthesis tasks performed during language
processing.
Front End Back End
Intermediate
Representation
(IR)
Source
Program
Target
Program
Intermediate Representation (IR)
Properties :-
1. Ease of use.
2. Processing efficiency.
3. Memory efficiency.
Fundamentals of Language Processing

Fundamentals of Language Processing

  • 2.
    Fundamentals of LanguageProcessing  Language Processing = Analysis of SP + Synthesis of TP  Collection of Language Processing components engaged in analysis a source program as the analysis phase and components engaged in synthesizing a target program constitute the synthesis phase.
  • 3.
    Analysis Phase  Thespecification consists of three components: 1. Lexical rules which govern the formation of valid lexical units in the source language. 2. Syntax rules which govern the formation of valid statements in the source language. 3. Semantic rules which associate meaning with valid statements of the language.
  • 4.
    Analysis Phase  Considerthe following example: percent_profit = (profit * 100) / cost_price  Lexical units identifies =, * and / operators, 100 as constant, and the remaining strings as identifiers.  Syntax analysis identifies the statement as an assignment statement with percent_profit as the left hand side and (profit * 100) / cost_price as the expression on the right hand side.  Semantic analysis determines the meaning of the statement to be the assignment of profit * 100 / cost_price to percent_profit.
  • 5.
    Synthesis Phase  Thesynthesis phase is concerned with the construction of target language statements which have the same meaning as a source statement.  It performs two main activities: 1. Creation of data structures in the target program (memory allocation) 2. Generation of target code (code generation)
  • 6.
    Phases & Passesof LP Language Processor  Analysis of source statements can not be immediately followed by synthesis of equivalent target statements due to following reasons: 1. Forward References 2. Issues concerning memory requirements and organization of a LP Analysis Phase Synthesis Phase Source Program Target Program ErrorsErrors
  • 7.
    Forward Reference  Itis a reference to the entity which precedes its definition in the program. Using a variable before a value is assigned to it is called a forward reference.  Forward referenced variables have the scope of the location where they are first referenced. They cannot be read before a value has been assigned to them, but they can be used for further forward reference.
  • 8.
    Language Processor Pass Pass I : performs analysis of Sorce Program and notes relevant information.  Pass II : performs synthesis of target program. Pass I analysis Source Program and generates IR which is given as input to Pass II to generate target code.
  • 9.
    Intermediate Representation (IR) An IR reflects the effect of some but not all, analysis and synthesis tasks performed during language processing. Front End Back End Intermediate Representation (IR) Source Program Target Program
  • 10.
    Intermediate Representation (IR) Properties:- 1. Ease of use. 2. Processing efficiency. 3. Memory efficiency.