SlideShare a Scribd company logo
COMPILER 
Achyuth Dorasala 
30-Sep-2014
INDEX 
TOPIC PAGE NO. 
1.COMPILER-DEFINATION ..... 03 
2.COMPILER-PHASES ..... 03 
A.ANALYSIS PHASE 
i.LEXICAL ANALYSIS ..... 03 
ii.SYNTAX ANALYSIS ..... 04 
iii.SEMANTIC ANALYSIS ..... 05 
B.SYNTHESIS ANALYSIS 
i.INTERMEDIATE CODE GENERATOR ..... 06 
ii.CODE OPTIMIZER ..... 06 
iii.CODE GENERATOR ..... 06 
3.STRUCTURE OF A COMPILER 
i.FRONT END ..... 07 
ii.MIDDLE END ..... 07 
iii.BACK END ..... 07 
4.COMPILER OUTPUT ..... 08 
5.NATIVE COMPILER ..... 08
6.CROSS COMPILER ..... 08 
7.VIRTUAL MACHINE ..... 08 
8.HARDWARE COMPILATION ..... 10 
9. COMPILER CORRECTNESS ..... 10 
10. RELATED TECHNIQUES ..... 10 
11.CROSS COMPILER ..... 11
COMPILER: 
A compiler is used to translate the high level language to machine level language 
COMPILER HAS TWO PHASES: 
A.ANALYSIS PHASE 
B.SYNTHESIS PHASE 
A.ANALYSIS PHASE: 
It will divide the source program into constituent pieces and create intermediate 
representation. 
An intermediate representation is any data structure that can represent the program 
without loss of information so that its execution can be conducted accurately. It serves as the 
common interface among the compiler components. 
the analysis phase can be divided into three parts 
1.Lexical Analysis 
2.Syntax Analysis 
3.semantic analysis 
1.LEXIAL ANALYSIS: 
the program is considered as a unique sequence of characters. It reads the program 
from left to right and sequence of characters is grouped into tokens. 
TOKENS 
A token is the smallest individual element in a program (identifiers,keywords 
,constants,operators)
lexical analyzer is the first phase of computer . The input for this is the source 
code. It identifies the different tokens in the source program. It is also called as “linear 
phase” or “linear analysis” or “scanning” . The output of this is sent to syntax analysis. 
for instance 
add = a + b ; 
lexical analyzer 
Here identifiers are = add,a,b 
operators are = =,+ 
separators are = ; 
this is all about lexical analysis. 
2.SYNTAX ANALYSIS: 
it is the second phase of the compiler. It is also called as parisng.it groups the 
tokens of source program into grammatical production , in short it gives parse tree. 
it checks whether the operator is in between the two operands are not , 
for instance, sum = a + b ; 
here the operator is ‘+’ . it checks only the operator but not the operands it means 
that if the one operand is the integer and other is string it will not give any error.it is also 
called as “Hierarchical Analysis” as it generates parse tree representation of the tokens.
ASSIGNMENT STATEMENT 
= 
IDENTIFIER SUM EXPRESSION 
+ 
OPERAND ‘a’ OPERAND ’b’ 
3.SEMANTIC ANALYSIS: 
syntax analyzer will just create parse tree. Semantic analyzer will check the meaning 
of the statement parsed in parse tree. It will compare the information in one part of a parse 
tree to that in another part. 
Semantic analysis is used for the following: 
1. maintaining the symbol table for each program. 
2.check for semantic errors in the source program. 
3.collecting type information for code generation. 
4.reporting the compilation errors. 
5.generating the object code.
Semantic analysis will check for the data type of first and second operand and checking for 
the number of operand based on operator in add = a + b. 
2.SYNTHESIS PHASE: 
it Generates the program from the intermediate representation. The synthesis 
part can be divided into three phases 
1.intermediate code generator 
2.code optimizer 
3.code generator 
1.INTERMEDIATE CODE GENERATOR: 
An intermediate code is generated as a program for an abstract machine. The 
intermediate code should be easy to translate to program. 
2.CODE OPTIMIZER: 
it improves the intermediate code such that fast runner code is generated. 
Different compilers obtain different optimization techniques. 
3.CODE GENERATOR: 
it generates the code which consists of assembly code. 
Here , memory locations are allotted separately for each variable.
STRUCTURE OF A COMPILER: 
1.FRONT END 
2.MIDDLE END 
3.BACK END 
1.FRONT END: 
it verifies syntax and semantics, and generates an intermediate 
representation of the source code for processing by the middle-end. performs type 
checking by collecting type information. it generates errors and warning, if any, in a useful 
way. aspects of the front end include lexical analysis, syntax analysis, and semantic analysis. 
2.MIDDLE END: 
It includes the removal of useless or unreachable code and generates 
other intermediate representation for the back end. 
3.BACK END: 
it generates the assembly code. 
SOME OF THE COMPANIES WHICH PROVIDE COMPILERS ARE: 
1. ABSINT 
2. FORTRAN 77 AND FORTRAN 90 FOR WINNT, WIN95, WIN3.1, LINUX, AND MACINTOSH. 
C/C++ FOR MACINTOSH. 
3. ADA CORE TECHNOLIGIES , AND SOME OTHER COMPANIES 
4. A WELL-DOCUMENTED EXAMPLE IS NIKLAUS WIRTH'S PL/0 COMPILER, WHICH WIRTH 
USED TO TEACH COMPILER CONSTRUCTION IN THE 1970,S
COMPILER OUTPUT 
One classification of compilers is by the platform on which their generated code 
executes. This is known as the target platform. 
NATIVE COMPILER: 
In which output is intended to directly run on the same type of 
computer and operating system . 
CROSS COMPILER: 
The output of a cross compiler is designed to run on a different 
platform. Cross compilers are often used when developing software for embedded 
systems that are not intended to support a software development environment . 
The output of a compiler that produces code for a virtual machine (VM) 
may or may not be executed on the same platform as the compiler that produced it. For this 
reason such compilers are not usually classified as native or cross compilers. 
VIRTUAL MACHINE: 
A virtual machine is a software implementation of a machine (for 
example, a computer) that executes programs like a physical machine(a hardware-based 
device like a personal computer)
HARDWARE COMPILATION: 
the output of some compilers may target computer hardware at a 
very low level , for example some compilers like application-specific integrated circuit,… 
Are known as hardware compilers because the source code compiled by them is the final 
configuration of the hardware. 
COMPILER CORRECTNESS: 
Compiler correctness is the branch of software engineering that deals 
with trying to show that a compiler behaves according to its language specification . 
Techniques include developing the compiler using formal methods and using rigorous 
testing (often called compiler validation) on an existing compiler. 
RELATED TECHNIQUES: 
assembly language is a type of low-level language and a program that 
compiles it is more commonly known as assembler , with the inverse program known as 
disassembler 
a program that translates from a low level language to a high level 
language is a decompiler . 
A program that translates between high-level languages is usually 
called a language translator, source to source translator, language converter, or 
language rewriter. The last term is usually applied to translations that do not involve a 
change of language.
CROSS COMPILER: 
A program that translates into an object code format that is not 
supported on the compilation machine is called a cross compiler and is commonly used to 
prepare code for embedded applications.
THANK YOU

More Related Content

PPT
Intermediate code generation (Compiler Design)
PPTX
Parsing in Compiler Design
PDF
Issues in the design of Code Generator
PPTX
Single pass assembler
PPTX
CLR AND LALR PARSER
PPT
Type Checking(Compiler Design) #ShareThisIfYouLike
PPT
Introduction to Compiler design
PPTX
Compilers
Intermediate code generation (Compiler Design)
Parsing in Compiler Design
Issues in the design of Code Generator
Single pass assembler
CLR AND LALR PARSER
Type Checking(Compiler Design) #ShareThisIfYouLike
Introduction to Compiler design
Compilers

What's hot (20)

PPT
4_5949547032388570388.ppt
PPTX
Computer Network Technology | Dynamic Host Configuration Protocol
PPTX
Instruction codes
PPTX
Oops in vb
PPTX
Non- Deterministic Algorithms
PPTX
Phases of Compiler
PDF
Lecture 01 introduction to compiler
PPTX
Constructor and Types of Constructors
PPT
phases of a compiler
PDF
Complete dbms notes
PPTX
Top down parsering and bottom up parsering.pptx
PPTX
Part I:Introduction to assembly language
PPT
PL/SQL Introduction and Concepts
PPT
Compiler Design Unit 1
PPT
Instruction format
PPT
1 - Introduction to PL/SQL
PPTX
Unit iv(simple code generator)
PPTX
Need of object oriented programming
PPTX
30. 8086 microprocessor pipelined architecture
4_5949547032388570388.ppt
Computer Network Technology | Dynamic Host Configuration Protocol
Instruction codes
Oops in vb
Non- Deterministic Algorithms
Phases of Compiler
Lecture 01 introduction to compiler
Constructor and Types of Constructors
phases of a compiler
Complete dbms notes
Top down parsering and bottom up parsering.pptx
Part I:Introduction to assembly language
PL/SQL Introduction and Concepts
Compiler Design Unit 1
Instruction format
1 - Introduction to PL/SQL
Unit iv(simple code generator)
Need of object oriented programming
30. 8086 microprocessor pipelined architecture
Ad

Similar to Compiler (20)

PDF
Compiler design
DOCX
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
PPTX
Chapter 1.pptx
PPT
A basic introduction to compiler design.ppt
PPT
A basic introduction to compiler design.ppt
PPTX
Ch 1.pptx
PPTX
Compiler presentaion
PDF
Chapter#01 cc
DOCX
Dineshmaterial1 091225091539-phpapp02
PPTX
Unit2_CD.pptx more about compilation of the day
PDF
Phases of compiler
DOCX
Compiler Design Material
PPT
Concept of compiler in details
PPTX
Chapter 1 Introduction.pptxhjgjghjghjhjhjhgjmjkhgk
PPTX
CSC 204 PASSES IN COMPILER CONSTURCTION.pptx
PDF
Principles of compiler design
PDF
unit1pdf__2021_12_14_12_37_34.pdf
PPTX
16 compiler-151129060845-lva1-app6892-converted.pptx
PDF
Lecture 2.1 - Phase of a Commmmpiler.pdf
PPTX
Pros and cons of c as a compiler language
Compiler design
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
Chapter 1.pptx
A basic introduction to compiler design.ppt
A basic introduction to compiler design.ppt
Ch 1.pptx
Compiler presentaion
Chapter#01 cc
Dineshmaterial1 091225091539-phpapp02
Unit2_CD.pptx more about compilation of the day
Phases of compiler
Compiler Design Material
Concept of compiler in details
Chapter 1 Introduction.pptxhjgjghjghjhjhjhgjmjkhgk
CSC 204 PASSES IN COMPILER CONSTURCTION.pptx
Principles of compiler design
unit1pdf__2021_12_14_12_37_34.pdf
16 compiler-151129060845-lva1-app6892-converted.pptx
Lecture 2.1 - Phase of a Commmmpiler.pdf
Pros and cons of c as a compiler language
Ad

Recently uploaded (20)

PDF
1_English_Language_Set_2.pdf probationary
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
IGGE1 Understanding the Self1234567891011
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
advance database management system book.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
History, Philosophy and sociology of education (1).pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Computing-Curriculum for Schools in Ghana
1_English_Language_Set_2.pdf probationary
UNIT III MENTAL HEALTH NURSING ASSESSMENT
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
Unit 4 Skeletal System.ppt.pptxopresentatiom
LDMMIA Reiki Yoga Finals Review Spring Summer
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Weekly quiz Compilation Jan -July 25.pdf
IGGE1 Understanding the Self1234567891011
Final Presentation General Medicine 03-08-2024.pptx
advance database management system book.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Final Presentation General Medicine 03-08-2024.pptx
History, Philosophy and sociology of education (1).pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Computing-Curriculum for Schools in Ghana

Compiler

  • 2. INDEX TOPIC PAGE NO. 1.COMPILER-DEFINATION ..... 03 2.COMPILER-PHASES ..... 03 A.ANALYSIS PHASE i.LEXICAL ANALYSIS ..... 03 ii.SYNTAX ANALYSIS ..... 04 iii.SEMANTIC ANALYSIS ..... 05 B.SYNTHESIS ANALYSIS i.INTERMEDIATE CODE GENERATOR ..... 06 ii.CODE OPTIMIZER ..... 06 iii.CODE GENERATOR ..... 06 3.STRUCTURE OF A COMPILER i.FRONT END ..... 07 ii.MIDDLE END ..... 07 iii.BACK END ..... 07 4.COMPILER OUTPUT ..... 08 5.NATIVE COMPILER ..... 08
  • 3. 6.CROSS COMPILER ..... 08 7.VIRTUAL MACHINE ..... 08 8.HARDWARE COMPILATION ..... 10 9. COMPILER CORRECTNESS ..... 10 10. RELATED TECHNIQUES ..... 10 11.CROSS COMPILER ..... 11
  • 4. COMPILER: A compiler is used to translate the high level language to machine level language COMPILER HAS TWO PHASES: A.ANALYSIS PHASE B.SYNTHESIS PHASE A.ANALYSIS PHASE: It will divide the source program into constituent pieces and create intermediate representation. An intermediate representation is any data structure that can represent the program without loss of information so that its execution can be conducted accurately. It serves as the common interface among the compiler components. the analysis phase can be divided into three parts 1.Lexical Analysis 2.Syntax Analysis 3.semantic analysis 1.LEXIAL ANALYSIS: the program is considered as a unique sequence of characters. It reads the program from left to right and sequence of characters is grouped into tokens. TOKENS A token is the smallest individual element in a program (identifiers,keywords ,constants,operators)
  • 5. lexical analyzer is the first phase of computer . The input for this is the source code. It identifies the different tokens in the source program. It is also called as “linear phase” or “linear analysis” or “scanning” . The output of this is sent to syntax analysis. for instance add = a + b ; lexical analyzer Here identifiers are = add,a,b operators are = =,+ separators are = ; this is all about lexical analysis. 2.SYNTAX ANALYSIS: it is the second phase of the compiler. It is also called as parisng.it groups the tokens of source program into grammatical production , in short it gives parse tree. it checks whether the operator is in between the two operands are not , for instance, sum = a + b ; here the operator is ‘+’ . it checks only the operator but not the operands it means that if the one operand is the integer and other is string it will not give any error.it is also called as “Hierarchical Analysis” as it generates parse tree representation of the tokens.
  • 6. ASSIGNMENT STATEMENT = IDENTIFIER SUM EXPRESSION + OPERAND ‘a’ OPERAND ’b’ 3.SEMANTIC ANALYSIS: syntax analyzer will just create parse tree. Semantic analyzer will check the meaning of the statement parsed in parse tree. It will compare the information in one part of a parse tree to that in another part. Semantic analysis is used for the following: 1. maintaining the symbol table for each program. 2.check for semantic errors in the source program. 3.collecting type information for code generation. 4.reporting the compilation errors. 5.generating the object code.
  • 7. Semantic analysis will check for the data type of first and second operand and checking for the number of operand based on operator in add = a + b. 2.SYNTHESIS PHASE: it Generates the program from the intermediate representation. The synthesis part can be divided into three phases 1.intermediate code generator 2.code optimizer 3.code generator 1.INTERMEDIATE CODE GENERATOR: An intermediate code is generated as a program for an abstract machine. The intermediate code should be easy to translate to program. 2.CODE OPTIMIZER: it improves the intermediate code such that fast runner code is generated. Different compilers obtain different optimization techniques. 3.CODE GENERATOR: it generates the code which consists of assembly code. Here , memory locations are allotted separately for each variable.
  • 8. STRUCTURE OF A COMPILER: 1.FRONT END 2.MIDDLE END 3.BACK END 1.FRONT END: it verifies syntax and semantics, and generates an intermediate representation of the source code for processing by the middle-end. performs type checking by collecting type information. it generates errors and warning, if any, in a useful way. aspects of the front end include lexical analysis, syntax analysis, and semantic analysis. 2.MIDDLE END: It includes the removal of useless or unreachable code and generates other intermediate representation for the back end. 3.BACK END: it generates the assembly code. SOME OF THE COMPANIES WHICH PROVIDE COMPILERS ARE: 1. ABSINT 2. FORTRAN 77 AND FORTRAN 90 FOR WINNT, WIN95, WIN3.1, LINUX, AND MACINTOSH. C/C++ FOR MACINTOSH. 3. ADA CORE TECHNOLIGIES , AND SOME OTHER COMPANIES 4. A WELL-DOCUMENTED EXAMPLE IS NIKLAUS WIRTH'S PL/0 COMPILER, WHICH WIRTH USED TO TEACH COMPILER CONSTRUCTION IN THE 1970,S
  • 9. COMPILER OUTPUT One classification of compilers is by the platform on which their generated code executes. This is known as the target platform. NATIVE COMPILER: In which output is intended to directly run on the same type of computer and operating system . CROSS COMPILER: The output of a cross compiler is designed to run on a different platform. Cross compilers are often used when developing software for embedded systems that are not intended to support a software development environment . The output of a compiler that produces code for a virtual machine (VM) may or may not be executed on the same platform as the compiler that produced it. For this reason such compilers are not usually classified as native or cross compilers. VIRTUAL MACHINE: A virtual machine is a software implementation of a machine (for example, a computer) that executes programs like a physical machine(a hardware-based device like a personal computer)
  • 10. HARDWARE COMPILATION: the output of some compilers may target computer hardware at a very low level , for example some compilers like application-specific integrated circuit,… Are known as hardware compilers because the source code compiled by them is the final configuration of the hardware. COMPILER CORRECTNESS: Compiler correctness is the branch of software engineering that deals with trying to show that a compiler behaves according to its language specification . Techniques include developing the compiler using formal methods and using rigorous testing (often called compiler validation) on an existing compiler. RELATED TECHNIQUES: assembly language is a type of low-level language and a program that compiles it is more commonly known as assembler , with the inverse program known as disassembler a program that translates from a low level language to a high level language is a decompiler . A program that translates between high-level languages is usually called a language translator, source to source translator, language converter, or language rewriter. The last term is usually applied to translations that do not involve a change of language.
  • 11. CROSS COMPILER: A program that translates into an object code format that is not supported on the compilation machine is called a cross compiler and is commonly used to prepare code for embedded applications.