Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

10. Parsing Data > Grammars and BNF Notation

Grammars and BNF Notation

A step past regexps and markup languages are full grammars in Backus Naur Form (BNF), most commonly used for parsing programming languages. They're also useful in protocol documents (e.g., the documentation for the HTTP standard that describes communication between web browsers and web servers; see http://www.w3.org/protocols/rfc1945/rfc1945) as a flexible means of enumerating the structure of a protocol. An example of a grammar for U.S. postal addresses (http://en.wikipedia.org/wiki/backus%e2%80%93naur_form) follows:

<postal-address> ::= <name-part> <street-address> <zip-part>

     <name-part> ::= <personal-part> <last-name> <opt-jr-part> <EOL>
                   | <personal-part> <name-part> <EOL>

 <personal-part> ::= <first-name> | <initial> "."

<street-address> ::= <opt-apt-num> <house-num> <street-name> <EOL>

      <zip-part> ::= <town-name> "," <state-code> <ZIP-code> <EOL>

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint