Backus Naur and Chomsky Normal Forms

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Backus Naur and Chomsky Normal Forms - Presentation Transcript

    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
    SlideShare Zeitgeist 2009

    + ashu1710ashu1710 Nominate

    custom

    172 views, 0 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 172
      • 172 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories