SlideShare a Scribd company logo
UNIT-III
Programming Language
• Lexical and Syntactic features of a
  programming Language are specified by its
  grammar
• Language:- collection of valid sentences.
• Sentences: These are the sequence of words.
• Word:- Sequence of letters of graphic symbols.
• The Language specified in this manner is
  called as formal Language.
Programming Language Grammar
• A formal Language is a set of rules which
  precisely specify the sentence of L.
• Formal Grammar can be represented as :-
• G= {∑ , NT, S, P}
  – ∑ set of terminals
  – NT set of non terminals
  – S Distinguished symbol (Starting symbol)
  – P set of productions.
• Terminal Symbol:- These are the symbols
  which can not further sub divided
  – Ex:- ∑= { a, b,c,d…….0,1,2,3……}
• No terminal symbols:- These are the
  combination of terminal symbols which can be
  further sub divided.
  – Ex:- <A> or <Noun>
• Production :- It is called as re-writing rule
• It can be represented as :-
   – Each production consists of a No terminal
     followed by an arrow (-) or equal to
     (=), followed by string of Non terminals and
     terminals
   – Ex:- A  b
          S  Aa
Syntax Tree


• A Graphical representation of any statement
  of a Language is called as syntax tree.
id+id*id



id
Derivation
• The replacement of Non terminal symbols
  according to the given production rule is
  called as derivation
• Types of Derivation:
  – Leftmost derivation
  – Rightmost derivation
Rules for English Language
1)   <Sentence>  <NP><VP>
2)   <NP>        <article><noun>
3)   <VP>        <verb>
4)   <VP>        <verb><adverb>
5)   <article>   The
6)   <noun>      student
7)   <verb>      studies
8)   <adverb>  hard
9)   <adverb>  slowly
Derivation
•   Structure                        Rules applied
•   <Sentence>
•   <NP><VP>                                  (1)
•   <article><noun>< VP>                      (2)
•   <article><noun> <verb><adverb>            (4)
•   The <noun> <verb><adverb>                 (5)
•   The student <verb> <adverb>               (6)
•   The student studies <adverb>              (7)
•   The student studies hard                  (8)
• Ex. Consider the full grammar,
•     E → E+E
•     E → E*E
•     E → id
•     Let us derive the string “ id + id * id”
Using leftmost derivation:-
Using Right most derivation:-
Rules
Required string is bbaa
• Derive the string

  –babbaaaba
System Programming Unit III
Required string is




   baab
System Programming Unit III
Reduction
• It is the process of replacement of string or
  part of string by non terminal according to the
  production rule.
•   Structure                       Rules applied
•   The student studies hard
•   <article> student studies hard            (5)
•   <article><noun> studies hard             (6)
•   <article><noun> <verb> hard              (7)
•   <article><noun> <verb> <adverb>          (8)
•   <NP> <verb> <adverb>                     (2)
•   <NP><VP>                                 (4)
•   <Sentence>                               (1)
Ambiguity of Grammar
• The Grammar for a language is said to be
  ambiguous if there exists at least one string
  which can be generated (or, derived) in more
  than one way
• i. e. there can be more than one leftmost
  derivations, more than one rightmost
  derivations & also more than one derivation
  trees associated with such a string.
• Ex. Consider the full grammar,
•     E → E+E
•     E → E*E
•     E → id
•     Let us derive the string “ id + id * id”
System Programming Unit III
System Programming Unit III
id   id
Compiler
• Complier:-
     • These are the system programs which will
       automatically translate the High level language
       program in to the machine language program

Source program                                 Target program /
High level Lang.           Compiler            M/C Lang. Prog.
Prog.



                           Database
• Cross Compiler:-
     • These are the system programs which will automatically
       translate the HLL program compatible with M/C A, in to the
       machine language program compatible with M/C A , but the
       underlying M/C is M/C B
Source program                                      Target program /
HLL Prog.                   Cross Compiler          M/C Lang. Prog.
Compatible with
M/C A



                               M/C B
P Code Compiler
 Source
Program


Compiler     P-Code interpreter



  Obj
Program



Exexute     P-Code interpreter
• Very similar in concept of Interpreter
• In pseudo- code complier program is analyzed
  and converted into an intermediate form,
  which is then executed interpretively.
• The source program is compiled, the resulted
  object program is in p-code. This p-code
  program is then read and executed under
  control of p-code interpreter.
Compilation process overview
• Compilation process is vast and complex.
• Hence it is divided into a series of subtasks
  called as phases.
• Each of which transform the source program
  form one representation to another.
• The compilation process involves two major
  tasks.
Compilation process overview

Analysis of   +    Synthesis of   =   Translation
source text       Target text         of prog in
                                      obj form
• Analysis of source text
  – Lexical Analysis (Scanner)
  – Syntax Analysis (Parser)
  – Semantic analysis.


• Synthesis of target text
  – Storage allocation
  – Code generation
Analysis of source text

• Determine validity of source statement from
  the analysis view point.
• Determine the content of source statement.
• Construct the suitable representation of the
  source statement f0r use by the subsequent
  analysis phase or by the synthesis phase of
  compiler.
Synthesis of target text

• Memory allocation:- It is the simple task given to
  the presence of symbol table. The memory
  requirement of an identifier is computed from its
  length, type and dimension and memory is
  allocated to it.
• Code generation:- the code generation uses the
  knowledge of target architecture , knowledge of
  instruction and also the addressing modes in the
  target computer to select the appropriate
  instruction.
Synthesis of target text

• The important issues in code generation are
  – Determine the space where the intermediate
    results should ne kept i.e. whether they should be
    kept in memory location or held in machine
    register.
  – Determine which instruction should be used for
    type conversion operation.
  – Determine which addressing mode should be
    used.
Phase Structure of Compiler
System Programming Unit III
System Programming Unit III
Code Optimization
• This is an optional phase to improve the
  intermediate code so that ultimate object
  program can run faster and also take less phase.
•     The ultimate aim of this technique is to
  improve the execution efficiency of a program by
  – Eliminating redundancies
  – Rearranging the computation in the program with out
    affecting target machine.
Code optimization techniques

1.   Compile time evaluation
2.   Elimination of common sub expressions
3.   Frequency reduction
4.   Strength reduction
5.   Dead code elimination
6.   Boolean sub expressions optimization
7.   Local and Global optimization.

More Related Content

What's hot (20)

PPT
Pipeline hazards in computer Architecture ppt
mali yogesh kumar
 
PDF
loaders and linkers
Temesgen Molla
 
PPTX
Ch 4 linker loader
Malek Sumaiya
 
PPTX
Linking in MS-Dos System
Satyamevjayte Haxor
 
PPTX
Register transfer language
Sanjeev Patel
 
PPTX
Memory Organization
Kamal Acharya
 
PPTX
Single source Shortest path algorithm with example
VINITACHAUHAN21
 
PPTX
Principal source of optimization in compiler design
Rajkumar R
 
PDF
Control Unit Design
Vinit Raut
 
PPTX
Code Generation
PrabuPappuR
 
PPTX
Algorithm analysis in fundamentals of data structure
Vrushali Dhanokar
 
PPTX
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I Core of Embedded Systems
Arti Parab Academics
 
PPTX
pipeline in computer architecture design
ssuser87fa0c1
 
PPT
Pass 1 flowchart
Namisha Sharma
 
PPTX
MACRO PROCESSOR
Bhavik Vashi
 
PPTX
Memory Reference Instructions
Rabin BK
 
PPTX
Dead Code Elimination
Samiul Ehsan
 
PPTX
Mapping
Syed Ali Sherazi
 
PPTX
Introduction to loaders
Tech_MX
 
PPTX
Code Optimization
Akhil Kaushik
 
Pipeline hazards in computer Architecture ppt
mali yogesh kumar
 
loaders and linkers
Temesgen Molla
 
Ch 4 linker loader
Malek Sumaiya
 
Linking in MS-Dos System
Satyamevjayte Haxor
 
Register transfer language
Sanjeev Patel
 
Memory Organization
Kamal Acharya
 
Single source Shortest path algorithm with example
VINITACHAUHAN21
 
Principal source of optimization in compiler design
Rajkumar R
 
Control Unit Design
Vinit Raut
 
Code Generation
PrabuPappuR
 
Algorithm analysis in fundamentals of data structure
Vrushali Dhanokar
 
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I Core of Embedded Systems
Arti Parab Academics
 
pipeline in computer architecture design
ssuser87fa0c1
 
Pass 1 flowchart
Namisha Sharma
 
MACRO PROCESSOR
Bhavik Vashi
 
Memory Reference Instructions
Rabin BK
 
Dead Code Elimination
Samiul Ehsan
 
Introduction to loaders
Tech_MX
 
Code Optimization
Akhil Kaushik
 

Similar to System Programming Unit III (20)

PPTX
Unit iii-111206004501-phpapp02
riddhi viradiya
 
PPTX
1 cc
Jay Soni
 
PDF
Unit1 cd
PRIST University
 
PDF
3_1_COMPILER_DESIGNGARGREREGREGREGREGREGRGRERE
solomonraju17
 
PDF
design intoduction of_COMPILER_DESIGN.pdf
advRajatSharma
 
PPTX
Compiler Design Introduction
Thapar Institute
 
DOC
Chapter 1 1
bolovv
 
DOCX
Cs6660 compiler design may june 2016 Answer Key
appasami
 
PPT
Compiler Construction
Sarmad Ali
 
PPT
Introduction to compiler
Abha Damani
 
DOC
Compilerdesignnew 091219090526-phpapp02
Anil Thakral
 
DOC
Compiler Design(Nanthu)
guest91cc85
 
DOC
Compiler Design(NANTHU NOTES)
guest251d9a
 
PPTX
Chapter 1.pptx
NesredinTeshome1
 
PPTX
role of lexical anaysis
Sudhaa Ravi
 
PPT
CC Week 11.ppt
KamranAli649587
 
PDF
Lecture 01 introduction to compiler
Iffat Anjum
 
PDF
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
ijistjournal
 
DOCX
Compiler Design Material
Dr. C.V. Suresh Babu
 
PPT
Concept of compiler in details
kazi_aihtesham
 
Unit iii-111206004501-phpapp02
riddhi viradiya
 
1 cc
Jay Soni
 
3_1_COMPILER_DESIGNGARGREREGREGREGREGREGRGRERE
solomonraju17
 
design intoduction of_COMPILER_DESIGN.pdf
advRajatSharma
 
Compiler Design Introduction
Thapar Institute
 
Chapter 1 1
bolovv
 
Cs6660 compiler design may june 2016 Answer Key
appasami
 
Compiler Construction
Sarmad Ali
 
Introduction to compiler
Abha Damani
 
Compilerdesignnew 091219090526-phpapp02
Anil Thakral
 
Compiler Design(Nanthu)
guest91cc85
 
Compiler Design(NANTHU NOTES)
guest251d9a
 
Chapter 1.pptx
NesredinTeshome1
 
role of lexical anaysis
Sudhaa Ravi
 
CC Week 11.ppt
KamranAli649587
 
Lecture 01 introduction to compiler
Iffat Anjum
 
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
ijistjournal
 
Compiler Design Material
Dr. C.V. Suresh Babu
 
Concept of compiler in details
kazi_aihtesham
 
Ad

More from Manoj Patil (10)

PDF
Smqa unit ii
Manoj Patil
 
PDF
Smqa unit v
Manoj Patil
 
PDF
Smqa unit iv
Manoj Patil
 
PDF
Smqa unit ii
Manoj Patil
 
PDF
Smqa unit i
Manoj Patil
 
PDF
Smqa unit iii
Manoj Patil
 
PPTX
System Programming Unit IV
Manoj Patil
 
PPTX
System Programming Unit II
Manoj Patil
 
PPTX
System Programming Unit II
Manoj Patil
 
PPTX
System Programing Unit 1
Manoj Patil
 
Smqa unit ii
Manoj Patil
 
Smqa unit v
Manoj Patil
 
Smqa unit iv
Manoj Patil
 
Smqa unit ii
Manoj Patil
 
Smqa unit i
Manoj Patil
 
Smqa unit iii
Manoj Patil
 
System Programming Unit IV
Manoj Patil
 
System Programming Unit II
Manoj Patil
 
System Programming Unit II
Manoj Patil
 
System Programing Unit 1
Manoj Patil
 
Ad

Recently uploaded (20)

PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 

System Programming Unit III

  • 2. Programming Language • Lexical and Syntactic features of a programming Language are specified by its grammar • Language:- collection of valid sentences. • Sentences: These are the sequence of words. • Word:- Sequence of letters of graphic symbols. • The Language specified in this manner is called as formal Language.
  • 3. Programming Language Grammar • A formal Language is a set of rules which precisely specify the sentence of L. • Formal Grammar can be represented as :- • G= {∑ , NT, S, P} – ∑ set of terminals – NT set of non terminals – S Distinguished symbol (Starting symbol) – P set of productions.
  • 4. • Terminal Symbol:- These are the symbols which can not further sub divided – Ex:- ∑= { a, b,c,d…….0,1,2,3……} • No terminal symbols:- These are the combination of terminal symbols which can be further sub divided. – Ex:- <A> or <Noun>
  • 5. • Production :- It is called as re-writing rule • It can be represented as :- – Each production consists of a No terminal followed by an arrow (-) or equal to (=), followed by string of Non terminals and terminals – Ex:- A  b S  Aa
  • 6. Syntax Tree • A Graphical representation of any statement of a Language is called as syntax tree.
  • 8. Derivation • The replacement of Non terminal symbols according to the given production rule is called as derivation • Types of Derivation: – Leftmost derivation – Rightmost derivation
  • 9. Rules for English Language 1) <Sentence>  <NP><VP> 2) <NP>  <article><noun> 3) <VP>  <verb> 4) <VP>  <verb><adverb> 5) <article>  The 6) <noun>  student 7) <verb>  studies 8) <adverb>  hard 9) <adverb>  slowly
  • 10. Derivation • Structure Rules applied • <Sentence> • <NP><VP> (1) • <article><noun>< VP> (2) • <article><noun> <verb><adverb> (4) • The <noun> <verb><adverb> (5) • The student <verb> <adverb> (6) • The student studies <adverb> (7) • The student studies hard (8)
  • 11. • Ex. Consider the full grammar, • E → E+E • E → E*E • E → id • Let us derive the string “ id + id * id”
  • 13. Using Right most derivation:-
  • 14. Rules
  • 16. • Derive the string –babbaaaba
  • 20. Reduction • It is the process of replacement of string or part of string by non terminal according to the production rule.
  • 21. Structure Rules applied • The student studies hard • <article> student studies hard (5) • <article><noun> studies hard (6) • <article><noun> <verb> hard (7) • <article><noun> <verb> <adverb> (8) • <NP> <verb> <adverb> (2) • <NP><VP> (4) • <Sentence> (1)
  • 22. Ambiguity of Grammar • The Grammar for a language is said to be ambiguous if there exists at least one string which can be generated (or, derived) in more than one way • i. e. there can be more than one leftmost derivations, more than one rightmost derivations & also more than one derivation trees associated with such a string.
  • 23. • Ex. Consider the full grammar, • E → E+E • E → E*E • E → id • Let us derive the string “ id + id * id”
  • 26. id id
  • 28. • Complier:- • These are the system programs which will automatically translate the High level language program in to the machine language program Source program Target program / High level Lang. Compiler M/C Lang. Prog. Prog. Database
  • 29. • Cross Compiler:- • These are the system programs which will automatically translate the HLL program compatible with M/C A, in to the machine language program compatible with M/C A , but the underlying M/C is M/C B Source program Target program / HLL Prog. Cross Compiler M/C Lang. Prog. Compatible with M/C A M/C B
  • 30. P Code Compiler Source Program Compiler P-Code interpreter Obj Program Exexute P-Code interpreter
  • 31. • Very similar in concept of Interpreter • In pseudo- code complier program is analyzed and converted into an intermediate form, which is then executed interpretively. • The source program is compiled, the resulted object program is in p-code. This p-code program is then read and executed under control of p-code interpreter.
  • 32. Compilation process overview • Compilation process is vast and complex. • Hence it is divided into a series of subtasks called as phases. • Each of which transform the source program form one representation to another. • The compilation process involves two major tasks.
  • 33. Compilation process overview Analysis of + Synthesis of = Translation source text Target text of prog in obj form
  • 34. • Analysis of source text – Lexical Analysis (Scanner) – Syntax Analysis (Parser) – Semantic analysis. • Synthesis of target text – Storage allocation – Code generation
  • 35. Analysis of source text • Determine validity of source statement from the analysis view point. • Determine the content of source statement. • Construct the suitable representation of the source statement f0r use by the subsequent analysis phase or by the synthesis phase of compiler.
  • 36. Synthesis of target text • Memory allocation:- It is the simple task given to the presence of symbol table. The memory requirement of an identifier is computed from its length, type and dimension and memory is allocated to it. • Code generation:- the code generation uses the knowledge of target architecture , knowledge of instruction and also the addressing modes in the target computer to select the appropriate instruction.
  • 37. Synthesis of target text • The important issues in code generation are – Determine the space where the intermediate results should ne kept i.e. whether they should be kept in memory location or held in machine register. – Determine which instruction should be used for type conversion operation. – Determine which addressing mode should be used.
  • 38. Phase Structure of Compiler
  • 41. Code Optimization • This is an optional phase to improve the intermediate code so that ultimate object program can run faster and also take less phase. • The ultimate aim of this technique is to improve the execution efficiency of a program by – Eliminating redundancies – Rearranging the computation in the program with out affecting target machine.
  • 42. Code optimization techniques 1. Compile time evaluation 2. Elimination of common sub expressions 3. Frequency reduction 4. Strength reduction 5. Dead code elimination 6. Boolean sub expressions optimization 7. Local and Global optimization.