SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (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)
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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...
 

Kürzlich hochgeladen

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 

Kürzlich hochgeladen (20)

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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​
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
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
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

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