Annotated edit history of
BackusNaurForm version 1, including all changes.
View license author blame.
| Rev |
Author |
# |
Line |
| 1 |
AristotlePagaltzis |
1 |
This is a language to define the formal grammar of a language, whether that be a ProgrammingLanguage, a MarkupLanguage or simply the syntax of a configuration file. |
| |
|
2 |
|
| |
|
3 |
An example grammar would be |
| |
|
4 |
|
| |
|
5 |
<sentance> ::= <verb-part> <noun-part> |
| |
|
6 |
|
| |
|
7 |
<verb-part> ::= <noun-part> <verb> |
| |
|
8 |
|
| |
|
9 |
<noun-part> ::= <proper-noun> |
| |
|
10 |
| THE <noun> |
| |
|
11 |
|
| |
|
12 |
<verb> ::= throws |
| |
|
13 |
| kicks |
| |
|
14 |
| hides |
| |
|
15 |
| fetches |
| |
|
16 |
|
| |
|
17 |
<proper-noun> ::= John |
| |
|
18 |
| Jane |
| |
|
19 |
|
| |
|
20 |
<noun> ::= ball |
| |
|
21 |
::= dog |
| |
|
22 |
|
| |
|
23 |
This grammar accepts sentances such as |
| |
|
24 |
* Jane throws the ball |
| |
|
25 |
* The dog fetches the ball |
| |
|
26 |
* John kicks the dog |
| |
|
27 |
* John hides Jane |
| |
|
28 |
* The ball fetches Jane |
| |
|
29 |
|
| |
|
30 |
but would not accept sentences such as |
| |
|
31 |
* John deflates the ball |
| |
|
32 |
* Jane hides in the basement |
| |
|
33 |
|
| |
|
34 |
because __deflates__ is not a verb known in this grammer and __in the basement__ is not a noun. The grammar would have to be extended to cover such cases. |
| |
|
35 |
|
| |
|
36 |
Because some common cases are inconvenient to define using pure [BNF], some extensions have been added in [EBNF]: |
| |
|
37 |
* __...__ means ''1 or more'' |
| |
|
38 |
* __[[ ]__ means ''optional'' |