J. Bense TonyAnna University        Chennai
Acompiler is a program that reads aprogram written in one language andtranslates into equivalent targetlanguage          ...
   The Front end checks whether the    program is correctly written in terms of the    programming language syntax and   ...
Front End :LexicalAnalysisPreprocessingSyntax AnalysisSemantic Analysis
Back End Analysis Optimization Code   generation
   Lexical Analyzer   Syntax Analyzer   Semantic Analyzer   Intermediate code generator   Code optimizer   Code gene...
Lexical                  Syntax                 SemanticSymbol                                  ErrorTable                ...
 Also called Linear Analysis Characters read from left to right and  grouped into tokens that are a sequence of  charact...
◦ Example◦ A=B+C◦ Variable tokens - A ,B, C◦ Symbolic token -- = +
   Also called as Hierarchial Analysis   A syntax tree[also called as parse tree] is generated    where    ◦ Operators ...
   Characters grouped as tokens in Lexical Analysis are    recorded as Tables. Checks for semantic errors   Collect TYPE...
   Sophisticated compilers typically perform multiple    passes over various intermediate forms.   Many algorithms for c...
 Input : Concrete Syntax Tree[Parse Tree] or           Abstract Syntax Tree The tree is converted into a linear sequence...
Concrete Parse tree             Abstract syntax treeConverted into a linear sequence of instructions       Results in 3AC ...
   This phase attempts to improve the intermediate    code inorder to increase the running time   Reduce the complexity ...
   Platform Dependant/ Platform Independent   Optimization can be automated by compilers or    performed by programmers...
 Succeeding step of Intermediate code  optimizer Consists of re-locatable machine  code/assembly code Intermediate inst...
 One   pass compilers Multi   pass compilers Load    and go compilers Optimizing   compilers
One pass                            Multi passPasses through the source code of   Processes the source code of aeach compi...
 Generates machine code and immediately  executes it. Compilers usually produce either absolute code that is executed im...
   Loop optimization   Data flow   Code generation   Functional language   Interprocedural optimizations   SSA [Stat...
Threaded code compiler database lookup program. replaces given strings in the source with  given binary code.   Increme...
   Stage compiler    That compiles to assembly language of a    theoretical machine, like some Prolog    implementations...
   A Retargetable compiler    ◦ object code is frequently of lesser quality than that      produced by a compiler develop...
 The compiler highlights all the possible  errors which are obstacle in the  program to provide a good meaning. Logical ...
   Array bound missing   Array size too large   Bad file name   Call of on function   Declaration missing   Compound...
   Not abstract   Not accessible   Not initialized   Not found in “import”   Scope related errors   Cannot be inheri...
   Program is free from lexical errors   Program is free from syntax errors   Program is free from semantic errors   E...
THANKYOU
Compilers
Upcoming SlideShare
Loading in...5
×

Compilers

2,674

Published on

Simple

Published in: Technology
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total Views
2,674
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
268
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Compilers"

  1. 1. J. Bense TonyAnna University Chennai
  2. 2. Acompiler is a program that reads aprogram written in one language andtranslates into equivalent targetlanguage COMPILER Source- - Target | | | Error Message
  3. 3.  The Front end checks whether the program is correctly written in terms of the programming language syntax and semantics The back end is responsible for translating the source into assembly code.
  4. 4. Front End :LexicalAnalysisPreprocessingSyntax AnalysisSemantic Analysis
  5. 5. Back End Analysis Optimization Code generation
  6. 6.  Lexical Analyzer Syntax Analyzer Semantic Analyzer Intermediate code generator Code optimizer Code generator
  7. 7. Lexical Syntax SemanticSymbol ErrorTable Handlermanager Intermediate Code Generator Code Generator Code Optimizer
  8. 8.  Also called Linear Analysis Characters read from left to right and grouped into tokens that are a sequence of characters with a collective meaningScans InputRemoves White spaces and commentsManufacture TokensGenerate Error if Any
  9. 9. ◦ Example◦ A=B+C◦ Variable tokens - A ,B, C◦ Symbolic token -- = +
  10. 10.  Also called as Hierarchial Analysis A syntax tree[also called as parse tree] is generated where ◦ Operators  Interior nodes ◦ Operands  Children of node for operators. = A + Interior B C Children
  11. 11.  Characters grouped as tokens in Lexical Analysis are recorded as Tables. Checks for semantic errors Collect TYPE information for the subsequent code generation phase
  12. 12.  Sophisticated compilers typically perform multiple passes over various intermediate forms. Many algorithms for code optimization are easier to apply one at a time The input to one optimization relies on the processing performed by another optimization
  13. 13.  Input : Concrete Syntax Tree[Parse Tree] or Abstract Syntax Tree The tree is converted into a linear sequence of instructions, usually in an intermediate language such as three address code. This is an Early stage of Code generation
  14. 14. Concrete Parse tree Abstract syntax treeConverted into a linear sequence of instructions Results in 3AC [ 3 Address Code]
  15. 15.  This phase attempts to improve the intermediate code inorder to increase the running time Reduce the complexity of the code generated Leading to a faster execution of the program Increased Performance
  16. 16.  Platform Dependant/ Platform Independent Optimization can be automated by compilers or performed by programmers Usually, the most powerful optimization is to find a superior algorithm. Include activities like ◦ Optimization of LOOPS ◦ Optimization of Bottlenecks
  17. 17.  Succeeding step of Intermediate code optimizer Consists of re-locatable machine code/assembly code Intermediate instructions are converted into a a sequence of machine instructions
  18. 18.  One pass compilers Multi pass compilers Load and go compilers Optimizing compilers
  19. 19. One pass Multi passPasses through the source code of Processes the source code of aeach compilation unit only once program several timesCompilation time is faster Compilation time is slowerHas limited scope of passes Has wide scope of passes.wide compilers Narrow compilersPascal Java
  20. 20.  Generates machine code and immediately executes it. Compilers usually produce either absolute code that is executed immediately upon conclusion of the compilation or object code that is transformed by a linking loader into absolute code.
  21. 21.  Loop optimization Data flow Code generation Functional language Interprocedural optimizations SSA [Static Single Assignment] based optimizations
  22. 22. Threaded code compiler database lookup program. replaces given strings in the source with given binary code. Incremental compiler: ◦ Individual functions can be compiled in a run-time environment that also includes interpreted functions.
  23. 23.  Stage compiler That compiles to assembly language of a theoretical machine, like some Prolog implementations Just-in-time compiler ◦ Applications are delivered in byte code, which is compiled to native machine code just prior to execution
  24. 24.  A Retargetable compiler ◦ object code is frequently of lesser quality than that produced by a compiler developed specifically for a processor. ◦ Retargetable compilers are often also cross compilers A parallelizing compiler ◦ converts a serial input program into a form suitable for efficient execution on a parallel computer architecture.
  25. 25.  The compiler highlights all the possible errors which are obstacle in the program to provide a good meaning. Logical errors could be found only at Run time of the program.
  26. 26.  Array bound missing Array size too large Bad file name Call of on function Declaration missing Compound statement missing Illegal Accessions
  27. 27.  Not abstract Not accessible Not initialized Not found in “import” Scope related errors Cannot be inherited Overloading Overriding errors
  28. 28.  Program is free from lexical errors Program is free from syntax errors Program is free from semantic errors Even a complex program could be compiled in a small interval of time In programs related to database accessing, many risks are reduced.
  29. 29. THANKYOU
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×