Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

- Bakus naur form by grahamwell 611 views
- Build a compiler using C#, Irony an... by James Curran 3573 views
- 25 bnf by kalyan krishna 502 views
- Content & Sponsorship Market Forces... by ASN 187 views
- Atestation BNF - Management de projet by Simionca Ioana-Maria 83 views
- Bnf 57 by Georgi Daskalov 79 views

No Downloads

Total views

4,704

On SlideShare

0

From Embeds

0

Number of Embeds

66

Shares

0

Downloads

0

Comments

0

Likes

7

No embeds

No notes for slide

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

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment