Академический Документы
Профессиональный Документы
Культура Документы
Program
+
Synthesis of Target
Program
ctd..
Language Processor
Source
Program
Analysis Phase
Synthesis
Phase
Errors
Errors
Target
Program
Lexical Analysis
Syntax Analysis
Semantic Analysis
Example
Analysis of Source statement
consider the statement
percent_profit = (profit*100) / cost_price;
Lexical Analysis: identification of =,*, / as a operators
percent_profit ,profit and cost_price as a
identifiers
and 100 as a constant
Syntax Analysis: Reveals the statement to be an assignment
statement
with percent_profit as the variable on left
hand side
and (profit*100) / cost_price as the
expression of
right hand side
Semantic Analysis: Deduces the meaning of the statement to be
Example
Source Statement: percent_profit = (profit*100) / cost_price;
Target Program:
MOVER
AREG, PROFIT
MULT
AREG, HUNDRED
DIV
AREG, COST_PRICE
MOVEM
AREG, PERCENT_PROFIT
PERCENT_PROFIT
DW
1
PROFIT
DW
1
COST_PRICE
DW
1
HUNDRED
DC
100
Source
Program
Analysis Phase
Errors
Synthesis
Synthesis Phase
Phase
Target
Program
Errors
Forward Reference
statement by-statement execution requires more memory
Example
A Language Processor having two passes
Front end
Back end
Intermediate
representation
(IR)
Target
Program
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.