Click here to load reader

C program compilation process

Embed Size (px)

Citation preview

C PROGRAM COMPILATION PROCESS

C PROGRAM COMPILATION PROCESS

COMPILATION PROCESS

STEPS IN COMPILATTION IN C

ANALYSIS- (follow pipelined approach)

SYNTHESIS- a non-pipelined approach

ANALYSIS AND SYNTHESIS

COMPILER PHASES

ANALYSIS LEXICAL ANALYSISThis analysis identify C tokens.Complete program is divided into number of token.printf(%d,x); Here, in above example printf, %d, a are C token

LEXICAL ANALYSIS(cont.)

SYNTAX ANALYSIS OR PARSERCheck syntax.Uses context free grammarTokens converted to parse tree using syntax analysisUses parsing i.e. top down parsing and bottom up parsing

SYNTAX ANALYSIS (cont.)

Parse tree generate by tokens using syntax analysis.

SEMANTIC ANALYSISIdentify static, dynamic, operational, denotation semanticsSemantic means meaning. It identify meaning of code means it check whether the code is written in proper order or not.It check meaning of codeType checking is performedContext free grammar are used

SYNTHESIS CODE GENERATION

CODE GENERATIONObject code is converted in pure machine code(10101111000110) or pure assembly code.Efficient compiler generate pure machine code.It uses forward reference table to store addressCode generation include hardware checking

CODE OPTIMIZATIONIt optimize code by reducing strength and decrease time consumptionRemove unnecessary code from program by showing warning message that it cannot be used in program.E.g - for(i=0;i