SlideShare a Scribd company logo
COMPILER DESIGN
INTRODUCTION
Richa Sharma 1
MAIN REFERENCE BOOK:
• COMPILERS – PRINCIPLES, TECHNIQUES AND TOOLS, SECOND EDITION BY
ALFRED V. AHO, RAVI SETHI, JEFFERY D. ULLMAN
• PRINCIPLES OF COMPILER DESIGN BY V R RAGHAVAN .
Richa Sharma 2
COMPILER
• IT’S A SOFTWARE UTILITY THAT TRANSLATED HIGH LANGUAGE CODE INTO TARGET LANGUAGE
CODE ,AS COMPUTER DOESN’T UNDERSTAND HIGH LANGUAGE.
DATA
OUTPUT
• IMPORTANT ROLE OF COMPILER IS TO REPORT THE ERROR IN THE SOURCE PROGRAM BY
TRANSLATING THE PROGRAM IN ONE GO.
• STRUCTURE OF THE COMPILER IS OFFLINE, MEANING THAT WE PRE-PROCESS THE PROGRAM FIRST
AND CREATES AND EXECUTABLE CODE AND THIS CODE CAN RUN ON DIFFERENT INPUTS OR DATA .
Richa Sharma 3
COMPILER
Source
Program
Target
Program
INTERPRETER
• IT’S ANOTHER SOFTWARE UTILITY THAT TRANSLATES HIGH LANGUAGE CODE INTO TARGET
LANGUAGE CODE LINE BY LINE UNLIKE COMPILER .
OUTPUT
• INTERPRETER IS ONLINE MODE, IN WHICH DATA AND SOURCE PROGRAM ARE EXECUTED
SIMULTANEOUSLY GIVING THE OUTPUT .NO PRE-PROCESSING IS DONE EARLIER.
Richa Sharma 4
COMPILER
Source Program
Data
EXAMPLES
MOST LANGUAGES ARE USUALLY THOUGHT OF AS USING EITHER
ONE OR THE OTHER:
• COMPILERS: FORTRAN, COBOL, C, C++, PASCAL, PL/1
• INTERPRETERS: LISP, SCHEME, BASIC, APL, PERL, PYTHON,
SMALLTALK
Richa Sharma 5
Preprocessor
Compiler
Assembler
Linker/Loader
Source program
Modified Source program
Target assembly program
Relocatable machine code
Target machine code
Library filesRicha Sharma
STEPS FOR LANGUAGE PROCESSING SYSTEM.
PHASES OF COMPILER
THE TRANSLATION OF INPUT FILE INTO TARGET CODE IS DIVIDED INTO 2 STAGES :
1. FRONT END (ANALYSIS): TRANSFORM SOURCE CODE INTO INTERMEDIATE CODE ALSO
CALLED INTERMEDIATE REPRESENTATION (IR) . IT’S A MACHINE-INDEPENDENT
REPRESENTATION.
2. BACK END (SYNTHESIS): IT TAKES IR AND GENERATES THE TARGET ASSEMBLY LANGUAGE
PROGRAM.
FRONT END BACK END
1) LEXICAL ANALYZER (SCANNING) 5) CODE OPTIMIZATION
2) SYNTAX ANALYZER (PARSING) 6) MACHINE CODE GENERATION
3) SEMANTIC ANALYZER
4) INTERMEDIATE CODE GENERATION
Richa Sharma 7
PHASES OF COMPILER
Richa Sharma 8
Symbol table Error handler
Front End
Back End
LEXICAL ANALYSIS/SCANNING
 READS THE STREAM OF CHARACTERS MAKING UP THE SOURCE PROGRAM AND GROUP THE
CHARACTERS INTO MEANINGFUL SEQUENCES CALLED LEXEMES.
 LEXEME ---- TOKEN
< TOKEN-NAME, ATTRIBUTE-VALUE>
 TOKEN NAME – IS AN ABSTRACT SYMBOL USED DURING SYNTAX ANALYSIS.
 ATTRIBUTE VALUE – POINTS TO AN ENTRY IN THE SYMBOL TABLE FOR THIS TOKEN.
POSITION = INITIAL + RATE * 60
<ID,1> < = > <ID,2> < +> <ID,3> < *> <60>
Richa Sharma 9
SYNTAX ANALYSIS/PARSING
• RECOGNIZES “SENTENCES” IN THE PROGRAM USING THE SYNTAX OF THE LANGUAGE
• CREATES TREE LIKE STRUCTURE FROM TOKENS (SYNTAX TREE)
• NODE REPRESENTS OPERATION
• CHILDREN REPRESENTS ARGUMENTS
• REPRESENTS THE SYNTACTIC STRUCTURE OF THE PROGRAM, HIDING A FEW DETAILS THAT ARE
IRRELEVENT TO LATER PHASES OF COMPILATION.
Richa Sharma 10
SEMANTIC ANALYSIS
• INFERS INFORMATION ABOUT THE PROGRAM USING THE SEMANTICS OF THE LANGUAGE
• USES SYNTAX TREE AND INFO. IN SYMBOL TABLE TO CHECK FOR SEMANTIC CONSISTENCY.
• GATHERS TYPE INFO. AND SAVES IT IN EITHER THE SYNTAX TREE OR SYMBOL TABLE FOR USE IN
ICG
• TYPE CHECKING – CHECKS THAT EACH OPERATOR HAS MATCHING OPERANDS. E.G ARRAY
INDEX SHOULD BE INTEGER.
• TYPE CONVERSIONS CALLED COERCIONS
• BINARY ARITHMETIC OPERATOR (INT OR FLOAT)
• IF 6+7.5, THEN CONVERT 6 TO 6.5
Richa Sharma 11
INTERMEDIATE CODE GENERATION
• GENERATES “ABSTRACT” CODE BASED ON THE SYNTACTIC STRUCTURE OF THE PROGRAM AND THE SEMANTIC
INFORMATION FROM PHASE 2.
 SYNTAX TREE ARE ALSO IR
 COMPILER MAY PRODUCE EXPLICIT IR
 IR HAS TWO PROPERTIES:
 EASY TO PRODUCE
 EASY TO TRANSLATE INTO TARGET MACHINE
 E.G IR – THREE ADDRESS CODE
 T1 = INTTOFLOAT(60)
 T2 = ID3 * T1
 T3 = ID2 + T3
 ID1 = T3
Richa Sharma 12
CODE OPTIMIZATION
• REFINES THE GENERATED CODE USING A SERIES OF OPTIMIZING TRANSFORMATIONS.
• Eg: REMOVING DEAD CODE .
REDUCING ITERATIONS AND LOOPS ETC..
• APPLY A SERIES OF TRANSFORMATIONS TO IMPROVE THE TIME AND SPACE EFFICIENCY OF THE
GENERATED CODE.
• PEEPHOLE OPTIMIZATIONS: GENERATE NEW INSTRUCTIONS BY COMBINING/EXPANDING ON
A SMALL NUMBER OF CONSECUTIVE INSTRUCTIONS.
• GLOBAL OPTIMIZATIONS: REORDER, REMOVE OR ADD INSTRUCTIONS TO CHANGE THE
STRUCTURE OF GENERATED CODE.
Richa Sharma 13
CODE GENEARTION
• MAP INSTRUCTIONS IN THE INTERMEDIATE CODE TO SPECIFIC MACHINE INSTRUCTIONS.
• SUPPORTS STANDARD OBJECT FILE FORMATS.
• GENERATES SUFFICIENT INFORMATION TO ENABLE SYMBOLIC DEBUGGING.
 IR -> CG -> TARGET LANGUAGE (E.G MACHINE CODE)
 REGISTERS AND MEMORY LOCATIONS ARE SELECTED FOR EACH VARIABLE USED BY THE PROGRAM.
 LDF R2, ID3
 MULF R2, R2, #60.0
 LDF R1, ID2
 ADDF R1, R1, R2
 STF ID1, R1
 R1,R2 – REGISTERS F – FLOATING POINT NUMBERS # - IMMEDIATE CONST.
Richa Sharma
14
SYMBOL TABLE
• SYMBOL TABLE – DATA STRUCTURE WITH A RECORD FOR EACH IDENTIFIER AND ITS ATTRIBUTES
• ALL THE PHASES ARE CONNECTED TO THE SYMBOL TABLE.
• ATTRIBUTES INCLUDE STORAGE ALLOCATION, TYPE, SCOPE, ETC
• ALL THE COMPILER PHASES INSERT AND MODIFY THE SYMBOL TABLE
Richa Sharma 15
Richa Sharma
16
OVERALL WORKING OF COMPILER PHASES
COMPILER CONSTRUCTION TOOLS
• DEVELOPER MAY USE MODERN SOFTWARE DEVELOPMENT ENVIRONMENT CONTAINING
TOOLS Ex: LANGUAGE EDITORS, VERSION MANAGERS, TEC.
• SOME SPECIAL TOOLS CAN ALSO BE USED. THESE TOOLS ARE THOSE WHICH HIDE THE DETAILS
OF GENERATION ALGORITHM AND PRODUCE COMPONENTS THAT CAN BE EASILY INTEGRATED
TO REMAINDER OF THE COMPILER.
• PARSER GENERATOR: TAKES GRAMMAR DESCRIPTION AND PRODUCES SYNTAX ANALYSER.
• SCANNER GENERATOR: TAKES REGULAR EXPRESSION AND PRODUCES LEXICAL ANALYSER.
• AUTOMATIC CODE- GENERATOR : TAKES INTERMEDIATE AND CONVERT TO MACHINE
LANGUAGE)
• DATA FLOW ANALYSIS ENGINES (FOR OPTIMIZATION)
• COMPILER CONSTRUCTION TOOLKIT.
Richa Sharma 17
APPLICATION OF COMPILER TECHNOLOGY
• IMPLEMENTATION OF HIGH LEVEL PROGRAMMING LANGUAGES
- CONCEPTS OF OOPS
• OPTIMIZATION FOR COMPUTER ARCHITECTURE
- PARALLELISM
- MEMORY HIERARCHIES OF MACHINES(REG, ARRAYS ETC)
• DESIGN OF NEW COMPUTER ARCHITECURES
- RISC
- CISC
- SIMD ETC
• PROGRAM TRANSLATIONS
• SOFTWARE PRODUCTIVITY TOOLS
Richa Sharma
18
Richa Sharma 19

More Related Content

What's hot

Parsing
ParsingParsing
Parsing
khush_boo31
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
Radhakrishnan Chinnusamy
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
desta_gebre
 
Compilers
CompilersCompilers
Compilers
Bense Tony
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
Radhakrishnan Chinnusamy
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
Akshaya Arunan
 
Compiler Construction
Compiler ConstructionCompiler Construction
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
Tasif Tanzim
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
Ahmad Idrees
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
Jothi Lakshmi
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
Farzana Aktar
 
Assembler
AssemblerAssembler
Assembler
manpreetgrewal
 
LALR Parser Presentation ppt
LALR Parser Presentation pptLALR Parser Presentation ppt
LALR Parser Presentation ppt
WPVKP.COM
 
Macro Processor
Macro ProcessorMacro Processor
Macro Processor
Saranya1702
 
Compiler design syntax analysis
Compiler design syntax analysisCompiler design syntax analysis
Compiler design syntax analysis
Richa Sharma
 
Lecture 04 syntax analysis
Lecture 04 syntax analysisLecture 04 syntax analysis
Lecture 04 syntax analysis
Iffat Anjum
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
Iffat Anjum
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
 
String functions in C
String functions in CString functions in C
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
sanchi29
 

What's hot (20)

Parsing
ParsingParsing
Parsing
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
Compilers
CompilersCompilers
Compilers
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Assembler
AssemblerAssembler
Assembler
 
LALR Parser Presentation ppt
LALR Parser Presentation pptLALR Parser Presentation ppt
LALR Parser Presentation ppt
 
Macro Processor
Macro ProcessorMacro Processor
Macro Processor
 
Compiler design syntax analysis
Compiler design syntax analysisCompiler design syntax analysis
Compiler design syntax analysis
 
Lecture 04 syntax analysis
Lecture 04 syntax analysisLecture 04 syntax analysis
Lecture 04 syntax analysis
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
String functions in C
String functions in CString functions in C
String functions in C
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
 

Similar to Compiler Design Introduction

Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
guest5de1a5
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
kazi_aihtesham
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
NesredinTeshome1
 
Intermediate Representation in Compiler Construction
Intermediate Representation in Compiler ConstructionIntermediate Representation in Compiler Construction
Intermediate Representation in Compiler Construction
theizm1
 
Compiler
CompilerCompiler
Single Pass Assembler
Single Pass AssemblerSingle Pass Assembler
Single Pass Assembler
Satyamevjayte Haxor
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
adilmehmood93
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
ahsaniftikhar19
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
venkatapranaykumarGa
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generation
Iffat Anjum
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
Preethi AKNR
 
1-Phases of compiler-26-04-2023.pptx
1-Phases of compiler-26-04-2023.pptx1-Phases of compiler-26-04-2023.pptx
1-Phases of compiler-26-04-2023.pptx
venkatapranaykumarGa
 
Compiler design
Compiler designCompiler design
Compiler design
suganyasanjai
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1
suganyasanjai
 
Embedded system design process
Embedded system design processEmbedded system design process
Embedded system design process
Rayees CK
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
Abha Damani
 
Principles of Compiler Design
Principles of Compiler DesignPrinciples of Compiler Design
Principles of Compiler Design
Marimuthu M
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
lec00-Introduction.pdf
lec00-Introduction.pdflec00-Introduction.pdf
lec00-Introduction.pdf
wigewej294
 

Similar to Compiler Design Introduction (20)

Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
 
Intermediate Representation in Compiler Construction
Intermediate Representation in Compiler ConstructionIntermediate Representation in Compiler Construction
Intermediate Representation in Compiler Construction
 
Compiler
CompilerCompiler
Compiler
 
Single Pass Assembler
Single Pass AssemblerSingle Pass Assembler
Single Pass Assembler
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generation
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
 
1-Phases of compiler-26-04-2023.pptx
1-Phases of compiler-26-04-2023.pptx1-Phases of compiler-26-04-2023.pptx
1-Phases of compiler-26-04-2023.pptx
 
Compiler design
Compiler designCompiler design
Compiler design
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1
 
Embedded system design process
Embedded system design processEmbedded system design process
Embedded system design process
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Principles of Compiler Design
Principles of Compiler DesignPrinciples of Compiler Design
Principles of Compiler Design
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
 
lec00-Introduction.pdf
lec00-Introduction.pdflec00-Introduction.pdf
lec00-Introduction.pdf
 

Recently uploaded

ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
nooriasukmaningtyas
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
PuktoonEngr
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
Madhumitha Jayaram
 

Recently uploaded (20)

ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
 

Compiler Design Introduction

  • 2. MAIN REFERENCE BOOK: • COMPILERS – PRINCIPLES, TECHNIQUES AND TOOLS, SECOND EDITION BY ALFRED V. AHO, RAVI SETHI, JEFFERY D. ULLMAN • PRINCIPLES OF COMPILER DESIGN BY V R RAGHAVAN . Richa Sharma 2
  • 3. COMPILER • IT’S A SOFTWARE UTILITY THAT TRANSLATED HIGH LANGUAGE CODE INTO TARGET LANGUAGE CODE ,AS COMPUTER DOESN’T UNDERSTAND HIGH LANGUAGE. DATA OUTPUT • IMPORTANT ROLE OF COMPILER IS TO REPORT THE ERROR IN THE SOURCE PROGRAM BY TRANSLATING THE PROGRAM IN ONE GO. • STRUCTURE OF THE COMPILER IS OFFLINE, MEANING THAT WE PRE-PROCESS THE PROGRAM FIRST AND CREATES AND EXECUTABLE CODE AND THIS CODE CAN RUN ON DIFFERENT INPUTS OR DATA . Richa Sharma 3 COMPILER Source Program Target Program
  • 4. INTERPRETER • IT’S ANOTHER SOFTWARE UTILITY THAT TRANSLATES HIGH LANGUAGE CODE INTO TARGET LANGUAGE CODE LINE BY LINE UNLIKE COMPILER . OUTPUT • INTERPRETER IS ONLINE MODE, IN WHICH DATA AND SOURCE PROGRAM ARE EXECUTED SIMULTANEOUSLY GIVING THE OUTPUT .NO PRE-PROCESSING IS DONE EARLIER. Richa Sharma 4 COMPILER Source Program Data
  • 5. EXAMPLES MOST LANGUAGES ARE USUALLY THOUGHT OF AS USING EITHER ONE OR THE OTHER: • COMPILERS: FORTRAN, COBOL, C, C++, PASCAL, PL/1 • INTERPRETERS: LISP, SCHEME, BASIC, APL, PERL, PYTHON, SMALLTALK Richa Sharma 5
  • 6. Preprocessor Compiler Assembler Linker/Loader Source program Modified Source program Target assembly program Relocatable machine code Target machine code Library filesRicha Sharma STEPS FOR LANGUAGE PROCESSING SYSTEM.
  • 7. PHASES OF COMPILER THE TRANSLATION OF INPUT FILE INTO TARGET CODE IS DIVIDED INTO 2 STAGES : 1. FRONT END (ANALYSIS): TRANSFORM SOURCE CODE INTO INTERMEDIATE CODE ALSO CALLED INTERMEDIATE REPRESENTATION (IR) . IT’S A MACHINE-INDEPENDENT REPRESENTATION. 2. BACK END (SYNTHESIS): IT TAKES IR AND GENERATES THE TARGET ASSEMBLY LANGUAGE PROGRAM. FRONT END BACK END 1) LEXICAL ANALYZER (SCANNING) 5) CODE OPTIMIZATION 2) SYNTAX ANALYZER (PARSING) 6) MACHINE CODE GENERATION 3) SEMANTIC ANALYZER 4) INTERMEDIATE CODE GENERATION Richa Sharma 7
  • 8. PHASES OF COMPILER Richa Sharma 8 Symbol table Error handler Front End Back End
  • 9. LEXICAL ANALYSIS/SCANNING  READS THE STREAM OF CHARACTERS MAKING UP THE SOURCE PROGRAM AND GROUP THE CHARACTERS INTO MEANINGFUL SEQUENCES CALLED LEXEMES.  LEXEME ---- TOKEN < TOKEN-NAME, ATTRIBUTE-VALUE>  TOKEN NAME – IS AN ABSTRACT SYMBOL USED DURING SYNTAX ANALYSIS.  ATTRIBUTE VALUE – POINTS TO AN ENTRY IN THE SYMBOL TABLE FOR THIS TOKEN. POSITION = INITIAL + RATE * 60 <ID,1> < = > <ID,2> < +> <ID,3> < *> <60> Richa Sharma 9
  • 10. SYNTAX ANALYSIS/PARSING • RECOGNIZES “SENTENCES” IN THE PROGRAM USING THE SYNTAX OF THE LANGUAGE • CREATES TREE LIKE STRUCTURE FROM TOKENS (SYNTAX TREE) • NODE REPRESENTS OPERATION • CHILDREN REPRESENTS ARGUMENTS • REPRESENTS THE SYNTACTIC STRUCTURE OF THE PROGRAM, HIDING A FEW DETAILS THAT ARE IRRELEVENT TO LATER PHASES OF COMPILATION. Richa Sharma 10
  • 11. SEMANTIC ANALYSIS • INFERS INFORMATION ABOUT THE PROGRAM USING THE SEMANTICS OF THE LANGUAGE • USES SYNTAX TREE AND INFO. IN SYMBOL TABLE TO CHECK FOR SEMANTIC CONSISTENCY. • GATHERS TYPE INFO. AND SAVES IT IN EITHER THE SYNTAX TREE OR SYMBOL TABLE FOR USE IN ICG • TYPE CHECKING – CHECKS THAT EACH OPERATOR HAS MATCHING OPERANDS. E.G ARRAY INDEX SHOULD BE INTEGER. • TYPE CONVERSIONS CALLED COERCIONS • BINARY ARITHMETIC OPERATOR (INT OR FLOAT) • IF 6+7.5, THEN CONVERT 6 TO 6.5 Richa Sharma 11
  • 12. INTERMEDIATE CODE GENERATION • GENERATES “ABSTRACT” CODE BASED ON THE SYNTACTIC STRUCTURE OF THE PROGRAM AND THE SEMANTIC INFORMATION FROM PHASE 2.  SYNTAX TREE ARE ALSO IR  COMPILER MAY PRODUCE EXPLICIT IR  IR HAS TWO PROPERTIES:  EASY TO PRODUCE  EASY TO TRANSLATE INTO TARGET MACHINE  E.G IR – THREE ADDRESS CODE  T1 = INTTOFLOAT(60)  T2 = ID3 * T1  T3 = ID2 + T3  ID1 = T3 Richa Sharma 12
  • 13. CODE OPTIMIZATION • REFINES THE GENERATED CODE USING A SERIES OF OPTIMIZING TRANSFORMATIONS. • Eg: REMOVING DEAD CODE . REDUCING ITERATIONS AND LOOPS ETC.. • APPLY A SERIES OF TRANSFORMATIONS TO IMPROVE THE TIME AND SPACE EFFICIENCY OF THE GENERATED CODE. • PEEPHOLE OPTIMIZATIONS: GENERATE NEW INSTRUCTIONS BY COMBINING/EXPANDING ON A SMALL NUMBER OF CONSECUTIVE INSTRUCTIONS. • GLOBAL OPTIMIZATIONS: REORDER, REMOVE OR ADD INSTRUCTIONS TO CHANGE THE STRUCTURE OF GENERATED CODE. Richa Sharma 13
  • 14. CODE GENEARTION • MAP INSTRUCTIONS IN THE INTERMEDIATE CODE TO SPECIFIC MACHINE INSTRUCTIONS. • SUPPORTS STANDARD OBJECT FILE FORMATS. • GENERATES SUFFICIENT INFORMATION TO ENABLE SYMBOLIC DEBUGGING.  IR -> CG -> TARGET LANGUAGE (E.G MACHINE CODE)  REGISTERS AND MEMORY LOCATIONS ARE SELECTED FOR EACH VARIABLE USED BY THE PROGRAM.  LDF R2, ID3  MULF R2, R2, #60.0  LDF R1, ID2  ADDF R1, R1, R2  STF ID1, R1  R1,R2 – REGISTERS F – FLOATING POINT NUMBERS # - IMMEDIATE CONST. Richa Sharma 14
  • 15. SYMBOL TABLE • SYMBOL TABLE – DATA STRUCTURE WITH A RECORD FOR EACH IDENTIFIER AND ITS ATTRIBUTES • ALL THE PHASES ARE CONNECTED TO THE SYMBOL TABLE. • ATTRIBUTES INCLUDE STORAGE ALLOCATION, TYPE, SCOPE, ETC • ALL THE COMPILER PHASES INSERT AND MODIFY THE SYMBOL TABLE Richa Sharma 15
  • 16. Richa Sharma 16 OVERALL WORKING OF COMPILER PHASES
  • 17. COMPILER CONSTRUCTION TOOLS • DEVELOPER MAY USE MODERN SOFTWARE DEVELOPMENT ENVIRONMENT CONTAINING TOOLS Ex: LANGUAGE EDITORS, VERSION MANAGERS, TEC. • SOME SPECIAL TOOLS CAN ALSO BE USED. THESE TOOLS ARE THOSE WHICH HIDE THE DETAILS OF GENERATION ALGORITHM AND PRODUCE COMPONENTS THAT CAN BE EASILY INTEGRATED TO REMAINDER OF THE COMPILER. • PARSER GENERATOR: TAKES GRAMMAR DESCRIPTION AND PRODUCES SYNTAX ANALYSER. • SCANNER GENERATOR: TAKES REGULAR EXPRESSION AND PRODUCES LEXICAL ANALYSER. • AUTOMATIC CODE- GENERATOR : TAKES INTERMEDIATE AND CONVERT TO MACHINE LANGUAGE) • DATA FLOW ANALYSIS ENGINES (FOR OPTIMIZATION) • COMPILER CONSTRUCTION TOOLKIT. Richa Sharma 17
  • 18. APPLICATION OF COMPILER TECHNOLOGY • IMPLEMENTATION OF HIGH LEVEL PROGRAMMING LANGUAGES - CONCEPTS OF OOPS • OPTIMIZATION FOR COMPUTER ARCHITECTURE - PARALLELISM - MEMORY HIERARCHIES OF MACHINES(REG, ARRAYS ETC) • DESIGN OF NEW COMPUTER ARCHITECURES - RISC - CISC - SIMD ETC • PROGRAM TRANSLATIONS • SOFTWARE PRODUCTIVITY TOOLS Richa Sharma 18