SlideShare une entreprise Scribd logo
1  sur  12
NOTES Title: Grammars for Compilers Intro to BNF Definition of BNF Example : http://otal.umd.edu/drweb/c++tutorial/lessons/BNF.HTM Variants of BNF: http://en.wikipedia.org/wiki/Backus–Naur_Form Why BNF? CNF Definition Characteristics BNF vs. CNF 10/26/2009 1 PESIT
Backus Naur and Chomsky Normal Forms Ashutosh Pandey 10/26/2009 2 PESIT
Backus-Naur Form Created by John Warner Backus (1927-2007) to describe the grammar of ALGOL, the first, widely used high-level language. The Backus–Naur Form or BNF grammars have significant similarities to Panini's Sanskrit grammar rules, and the notation is sometimes also referred to as Panini–Backus Form. 10/26/2009 3 PESIT
Definition of BNF A BNF specification consists of a set of production rules written as:- <variable> ::= <expression> where   <variable>  is a non-terminal symbol <expression> consists of  one or more sequences of terminal and non-terminal symbol and each sequence is separated by the ‘ | ‘ symbol. Terminal symbols cannot appear on the left side of a production  10/26/2009 4 PESIT
Example of BNF BNF Specification of the C++ grammar:- <c++prog> ::= <sysdirectives> <decdefs> main () {<body>} <sysdirectives> ::= ‘ ‘| #<includedir> <includedir> ::= include '<'<filename>'>‘ . . . <body> ::= | <statement> | <decdef> |<body> <statement> | <body> <decdef> <statement> ::= <assignment>; | <inputstatement>; | <outputstatement>; | <condstatement>; | <iterativestatement>; <assignment> ::= <id>++ | ++<id> | <id>-- | --<id> | <equalassign> … 10/26/2009 5 PESIT
Variants of BNF Many variations of the BNF exist, for the sake of simplicity, and readability Extended BNF (EBNF) is a popular variant, which uses regular expression repetition operators such as ‘+’ or ‘*’ Reduced BNF (RBNF) is used to encode rules of various routing protocols. 10/26/2009 6 PESIT
Advantages of BNF  High human readability: BNF is informal in nature. Ease in Parsing: simple LL parsers are sufficient. Ease of adaptability: Can be customized for various application due to it’s informal nature 10/26/2009 7 PESIT
Who uses BNF? YACC Definitions of markup languages such as XML (HTML does not have a grammar). GOLD: A freeware parsing system. Other parser generators for JAVA(Parser Objects), Python (Wormhole). 10/26/2009 8 PESIT
Chomsky Normal Form A grammar is in the Chomsky normal form if all it’s productions are of the form :- S  AB A  a Where S is the start variable, AB are any two non – terminal symbol and a is a terminal symbol.  10/26/2009 9 PESIT
Characteristics of CNF Every parse tree is a binary tree with    2n – 1 nodes, where n is the length of the string to be parsed. No Ambiguity. Uses the CYK Algorithm whose time complexity is Θ(2n- 1), therefore efficient parsing is another characteristic Every context-free grammar can be efficiently converted in to CNF. 10/26/2009 10 PESIT
Uses of CNF Required for some efficient parsing algorithms such as Cocke-Younger-Kasami (CYK) algorithm Used for proofs in the field of languages and computability because of its linear order of growth. 10/26/2009 11 PESIT
BNF vs. CNF BNF Easily understood by humans. Useful for Parser Generators. Uses LL, LR, LALR Parsing algorithms. CNF Often difficult to understand. Useful for theorem proving. Uses the CYK Parsing algorithm 10/26/2009 12 PESIT

Contenu connexe

Tendances

Tendances (20)

Lecture 5
Lecture 5Lecture 5
Lecture 5
 
LR Parsing
LR ParsingLR Parsing
LR Parsing
 
Top down and botttom up Parsing
Top down     and botttom up ParsingTop down     and botttom up Parsing
Top down and botttom up Parsing
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Lecture: Word Sense Disambiguation
Lecture: Word Sense DisambiguationLecture: Word Sense Disambiguation
Lecture: Word Sense Disambiguation
 
Challenges in nlp
Challenges in nlpChallenges in nlp
Challenges in nlp
 
First order logic
First order logicFirst order logic
First order logic
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammar
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Regular Expression Examples.pptx
Regular Expression Examples.pptxRegular Expression Examples.pptx
Regular Expression Examples.pptx
 
Theory of Computation
Theory of ComputationTheory of Computation
Theory of Computation
 
Lesson 05
Lesson 05Lesson 05
Lesson 05
 
Logic (slides)
Logic (slides)Logic (slides)
Logic (slides)
 
Yacc
YaccYacc
Yacc
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Nlp ambiguity presentation
Nlp ambiguity presentationNlp ambiguity presentation
Nlp ambiguity presentation
 
3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 

En vedette

Bakus naur form
Bakus naur formBakus naur form
Bakus naur formgrahamwell
 
Chomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsChomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsRajendran
 
Normal forms cfg
Normal forms   cfgNormal forms   cfg
Normal forms cfgRajendran
 
Chomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanChomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanM Khan
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationDrishti Bhalla
 
邏輯語為何從BNF轉向PEG ?
邏輯語為何從BNF轉向PEG ?邏輯語為何從BNF轉向PEG ?
邏輯語為何從BNF轉向PEG ?鍾誠 陳鍾誠
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languagesVarun Garg
 
3D Voxel Worlds with voxel.js
3D Voxel Worlds with voxel.js3D Voxel Worlds with voxel.js
3D Voxel Worlds with voxel.jsVlad Filippov
 
PUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEPUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEAbhishek Shivhare
 
Dynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter GenerationDynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter GenerationEelco Visser
 
Turing Machine
Turing MachineTuring Machine
Turing MachineAyAn KhAn
 
Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Akshay Nagpurkar
 
Oracle PL/SQL exception handling
Oracle PL/SQL exception handlingOracle PL/SQL exception handling
Oracle PL/SQL exception handlingSmitha Padmanabhan
 

En vedette (20)

Bakus naur form
Bakus naur formBakus naur form
Bakus naur form
 
Chomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsChomsky & Greibach Normal Forms
Chomsky & Greibach Normal Forms
 
Normal forms cfg
Normal forms   cfgNormal forms   cfg
Normal forms cfg
 
Chomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanChomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel Khan
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of Computation
 
Bnf and ambiquity
Bnf and ambiquityBnf and ambiquity
Bnf and ambiquity
 
邏輯語為何從BNF轉向PEG ?
邏輯語為何從BNF轉向PEG ?邏輯語為何從BNF轉向PEG ?
邏輯語為何從BNF轉向PEG ?
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
Turing machine by_deep
Turing machine by_deepTuring machine by_deep
Turing machine by_deep
 
3D Voxel Worlds with voxel.js
3D Voxel Worlds with voxel.js3D Voxel Worlds with voxel.js
3D Voxel Worlds with voxel.js
 
25 bnf
25 bnf25 bnf
25 bnf
 
PUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEPUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINE
 
Dynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter GenerationDynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter Generation
 
Applying SOS to MDE
Applying SOS to MDEApplying SOS to MDE
Applying SOS to MDE
 
Minimization of dfa
Minimization of dfaMinimization of dfa
Minimization of dfa
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
Oracle PL/SQL exception handling
Oracle PL/SQL exception handlingOracle PL/SQL exception handling
Oracle PL/SQL exception handling
 
Parsing
ParsingParsing
Parsing
 

Similaire à Backus Naur and Chomsky Normal Forms

Please follow the data and description EBNF In the stream of c.pdf
Please follow the data and description EBNF In the stream of c.pdfPlease follow the data and description EBNF In the stream of c.pdf
Please follow the data and description EBNF In the stream of c.pdfanujmkt
 
An Application Using Writer as a GUI for Creating and Maintaining [e]BNFs
An Application Using Writer as a GUI for Creating and Maintaining [e]BNFsAn Application Using Writer as a GUI for Creating and Maintaining [e]BNFs
An Application Using Writer as a GUI for Creating and Maintaining [e]BNFsAlexandro Colorado
 
P REPROCESSING FOR PPM: COMPRESSING UTF - 8 ENCODED NATURAL LANG UAGE TEXT
P REPROCESSING FOR PPM: COMPRESSING  UTF - 8 ENCODED NATURAL LANG UAGE TEXTP REPROCESSING FOR PPM: COMPRESSING  UTF - 8 ENCODED NATURAL LANG UAGE TEXT
P REPROCESSING FOR PPM: COMPRESSING UTF - 8 ENCODED NATURAL LANG UAGE TEXTijcsit
 
P REPROCESSING FOR PPM: COMPRESSING UTF - 8 ENCODED NATURAL LANG UAGE TEXT
P REPROCESSING FOR PPM: COMPRESSING  UTF - 8 ENCODED NATURAL LANG UAGE TEXTP REPROCESSING FOR PPM: COMPRESSING  UTF - 8 ENCODED NATURAL LANG UAGE TEXT
P REPROCESSING FOR PPM: COMPRESSING UTF - 8 ENCODED NATURAL LANG UAGE TEXTijcsit
 
Corpus Linguistics :Analytical Tools
Corpus Linguistics :Analytical ToolsCorpus Linguistics :Analytical Tools
Corpus Linguistics :Analytical ToolsJitendra Patil
 
Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...
Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...
Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...Stefan Marr
 
Controlled Natural Language Generation from a Multilingual FrameNet-based Gra...
Controlled Natural Language Generation from a Multilingual FrameNet-based Gra...Controlled Natural Language Generation from a Multilingual FrameNet-based Gra...
Controlled Natural Language Generation from a Multilingual FrameNet-based Gra...Normunds Grūzītis
 

Similaire à Backus Naur and Chomsky Normal Forms (10)

Please follow the data and description EBNF In the stream of c.pdf
Please follow the data and description EBNF In the stream of c.pdfPlease follow the data and description EBNF In the stream of c.pdf
Please follow the data and description EBNF In the stream of c.pdf
 
An Application Using Writer as a GUI for Creating and Maintaining [e]BNFs
An Application Using Writer as a GUI for Creating and Maintaining [e]BNFsAn Application Using Writer as a GUI for Creating and Maintaining [e]BNFs
An Application Using Writer as a GUI for Creating and Maintaining [e]BNFs
 
P REPROCESSING FOR PPM: COMPRESSING UTF - 8 ENCODED NATURAL LANG UAGE TEXT
P REPROCESSING FOR PPM: COMPRESSING  UTF - 8 ENCODED NATURAL LANG UAGE TEXTP REPROCESSING FOR PPM: COMPRESSING  UTF - 8 ENCODED NATURAL LANG UAGE TEXT
P REPROCESSING FOR PPM: COMPRESSING UTF - 8 ENCODED NATURAL LANG UAGE TEXT
 
P REPROCESSING FOR PPM: COMPRESSING UTF - 8 ENCODED NATURAL LANG UAGE TEXT
P REPROCESSING FOR PPM: COMPRESSING  UTF - 8 ENCODED NATURAL LANG UAGE TEXTP REPROCESSING FOR PPM: COMPRESSING  UTF - 8 ENCODED NATURAL LANG UAGE TEXT
P REPROCESSING FOR PPM: COMPRESSING UTF - 8 ENCODED NATURAL LANG UAGE TEXT
 
Meta Languages
Meta LanguagesMeta Languages
Meta Languages
 
Corpus Linguistics :Analytical Tools
Corpus Linguistics :Analytical ToolsCorpus Linguistics :Analytical Tools
Corpus Linguistics :Analytical Tools
 
56 o oo ccf_final
56 o oo ccf_final56 o oo ccf_final
56 o oo ccf_final
 
Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02
 
Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...
Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...
Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...
 
Controlled Natural Language Generation from a Multilingual FrameNet-based Gra...
Controlled Natural Language Generation from a Multilingual FrameNet-based Gra...Controlled Natural Language Generation from a Multilingual FrameNet-based Gra...
Controlled Natural Language Generation from a Multilingual FrameNet-based Gra...
 

Dernier

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Dernier (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Backus Naur and Chomsky Normal Forms

  • 1. NOTES Title: Grammars for Compilers Intro to BNF Definition of BNF Example : http://otal.umd.edu/drweb/c++tutorial/lessons/BNF.HTM Variants of BNF: http://en.wikipedia.org/wiki/Backus–Naur_Form Why BNF? CNF Definition Characteristics BNF vs. CNF 10/26/2009 1 PESIT
  • 2. Backus Naur and Chomsky Normal Forms Ashutosh Pandey 10/26/2009 2 PESIT
  • 3. Backus-Naur Form Created by John Warner Backus (1927-2007) to describe the grammar of ALGOL, the first, widely used high-level language. The Backus–Naur Form or BNF grammars have significant similarities to Panini's Sanskrit grammar rules, and the notation is sometimes also referred to as Panini–Backus Form. 10/26/2009 3 PESIT
  • 4. Definition of BNF A BNF specification consists of a set of production rules written as:- <variable> ::= <expression> where <variable> is a non-terminal symbol <expression> consists of one or more sequences of terminal and non-terminal symbol and each sequence is separated by the ‘ | ‘ symbol. Terminal symbols cannot appear on the left side of a production 10/26/2009 4 PESIT
  • 5. Example of BNF BNF Specification of the C++ grammar:- <c++prog> ::= <sysdirectives> <decdefs> main () {<body>} <sysdirectives> ::= ‘ ‘| #<includedir> <includedir> ::= include '<'<filename>'>‘ . . . <body> ::= | <statement> | <decdef> |<body> <statement> | <body> <decdef> <statement> ::= <assignment>; | <inputstatement>; | <outputstatement>; | <condstatement>; | <iterativestatement>; <assignment> ::= <id>++ | ++<id> | <id>-- | --<id> | <equalassign> … 10/26/2009 5 PESIT
  • 6. Variants of BNF Many variations of the BNF exist, for the sake of simplicity, and readability Extended BNF (EBNF) is a popular variant, which uses regular expression repetition operators such as ‘+’ or ‘*’ Reduced BNF (RBNF) is used to encode rules of various routing protocols. 10/26/2009 6 PESIT
  • 7. Advantages of BNF High human readability: BNF is informal in nature. Ease in Parsing: simple LL parsers are sufficient. Ease of adaptability: Can be customized for various application due to it’s informal nature 10/26/2009 7 PESIT
  • 8. Who uses BNF? YACC Definitions of markup languages such as XML (HTML does not have a grammar). GOLD: A freeware parsing system. Other parser generators for JAVA(Parser Objects), Python (Wormhole). 10/26/2009 8 PESIT
  • 9. Chomsky Normal Form A grammar is in the Chomsky normal form if all it’s productions are of the form :- S  AB A  a Where S is the start variable, AB are any two non – terminal symbol and a is a terminal symbol. 10/26/2009 9 PESIT
  • 10. Characteristics of CNF Every parse tree is a binary tree with 2n – 1 nodes, where n is the length of the string to be parsed. No Ambiguity. Uses the CYK Algorithm whose time complexity is Θ(2n- 1), therefore efficient parsing is another characteristic Every context-free grammar can be efficiently converted in to CNF. 10/26/2009 10 PESIT
  • 11. Uses of CNF Required for some efficient parsing algorithms such as Cocke-Younger-Kasami (CYK) algorithm Used for proofs in the field of languages and computability because of its linear order of growth. 10/26/2009 11 PESIT
  • 12. BNF vs. CNF BNF Easily understood by humans. Useful for Parser Generators. Uses LL, LR, LALR Parsing algorithms. CNF Often difficult to understand. Useful for theorem proving. Uses the CYK Parsing algorithm 10/26/2009 12 PESIT