Solved

BNF specification

Posted on 2001-09-18
5
479 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
>>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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now