Designer Software
Posted on Saturday, September 3rd, 2011 at 6:08 pmDesigner Software
Someone explain BNF and EBNF in an easy to understand way to a novice software designer
?
For my upcoming exams, if having some trouble getting my head around it.
BNF (“Backus-Naur form”) is a way to specify the grammatical structure of a language. For example, you could describe the language of mathematical expressions as something like…
|
|
Then, an expression can be just a number (e.g. “3″), or two expressions joined by an operator (e.g. “3 + 5″), or parentheses around another expression (e.g. “(3)”), or some nested combination (e.g. “3 + (9 – 4) ^ 2″).
It’s normally used to describe the syntax of a programming language; there are tools used for writing compilers/interpreters that take a description of the grammar in BNF (or EBNF) and produce code that can read in a program and break it down into its syntactic components. EBNF (“extended Backus-Naur form”) extends the syntax to include optional or repeated sections, such as
list = { element };
number = [ sign ] { digit };
Any grammar that can be described in EBNF can also be described in BNF, but EBNF often makes the description simpler.