BNF specification

What does BNF (Backus Naur Format) specification mean and what other format specifications exist?
Who is Participating?
jhanceConnect With a Mentor Commented:
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.
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.
bobbybioAuthor Commented:
Thank you for your immediate answer! But is this method something like  rules of coding or something else? How is it used?
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.

>>other format specifications exist?
ABNF (Augmented BNF)
RDF specifications
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.