728x15 Ads

bar

phases of compiler


Phases of Compiler
SOURCE PROGRAM
(HIGH LEVEL LANGUAGE)
        
LEXICAL ANALYSIS:-
Lexical analysis phase main hum user se input lete hai aur usse characters ko alag karte hai ,un group of characters ko token kahte hai.
     Keywords jaise ki do,if
Aur identifiers jaise x,num aur koi bhi variable token hote hain

EXAMPLE:-
               a=b+r*60
                   inme token hai
a). identifier=a,b,r;
b).operator==,+,*
c).constant number=60

SYNTAX ANALYSIS:-
es phase main token ko parse tree main change karte hai
EXAMPLE:=
                a=b+r*60
Parse tree

                                                            
                                     

                                                                                                            
                                                                                                                                      
INTERMEDIATE CODE GENERATION
is phase main hum simple instruction likhte hai postfix ya triples forms main.
EXAMPLE:-
   a=b+r*60
Intermediate code is     
                                                Temp1<-intoread(60)
                                                Temp2<-r*temp1
                                                Temp3<-b+temp2
                                                A<-temp3

CODE OPTIMIZATION:-
Ye phase optional phase hota hai .isme hum intermediate code se redundancies ko dur karte hai.
Example :-
         A=b+r*60
Code optimization of above intermediate code is
       Temp1=r*60;
      a=b+temp1




CODE GENERATION:
Ye compile ka last phase hota hai isme hum simple machine instruction likhte hai jo ki optimize instruction ho.
EXAMPLE:-
MOVF  r R2
MULF #60.0 R2
MOVF b R1
ADDF R2 R1
MOVF R a
TABLE MANAGEMENT :
Table management table variables ki information store karke rakhta hai.
ERROR HANDLER:
Error handler program main error check karta hai agar program main kahi error ho to wo programmer ko message deta hai ki kis line me error hai.

Copyright © eAZy EnginEEriNG