Solved

BNF specification

Posted on 2001-09-18
5
489 Views
Last Modified: 2008-02-26
What does BNF (Backus Naur Format) specification mean and what other format specifications exist?
Thanks!
0
Comment
Question by:bobbybio
5 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 6490470
BNF is a rigourous method for defining a language syntax.  It's by far the most common method used and taught.  There are others but I'm unfamiliar with their names and have never used anything else.
0
 

Author Comment

by:bobbybio
ID: 6490888
Thank you for your immediate answer! But is this method something like  rules of coding or something else? How is it used?
0
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
ID: 6490962
I suppose it could be used and most likely is used for that purpose.  But my experience is that it's most useful to language developers, compiler developers, and students.

Using BNF is a good way to ensure that a language is "parsable".  If the rules for the language are inconsistent, building a parser for the compiler is very difficult.  Since the BNF helps in the design and even analysis of a language, you have a valuable tool.

You might say that you don't need it since you may not ever develop a C++ compiler or parser but it is also quite useful in just about any specification or documentation that will end up being "read" by a computer program.

For exmaple, even things like HTML, XML, SGML, most database languages (like SQL), etc. can and do make use of BNF specifications.
0
 
LVL 1

Expert Comment

by:dspector
ID: 6491614
BNF (Backus/Naur Form) is a language that specifies the strings of a language. The symbols forming the string can be anything (a 'token'). They may be characters, or entities such as 'identifiers' made up of characters.

Here are some typical (extended) BNF 'productions':

ID ::= <letter> <alphanumeric> | ID <alphanumeric>
<letter> :: 'a' | 'b' | 'c' | ...
<alphanumeric> ::= <digit> | <letter>
<digit> ::= '0' | '1' | ...

These mean that an identifier (ID) is a letter followed by any number of alphanumeric characters, where an alphanumeric is defined as any digit or letter.

The '|' means an alternate derivation (this is an extension to BNF, and only makes the BNF easier to read).

Let me know if there is anything else you would like to know; I spent years writing parsers and other tools that used BNF.

David
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6492641
>>other format specifications exist?
ABNF (Augmented BNF)
http://community.roxen.com/developers/idocs/rfc/rfc2234.html
RDF specifications
http://www.ics.uci.edu/~rohit/cscw98/rdf/
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question