418
|
1 |
-*- mode: outline; coding: utf-8 -*-
|
|
2 |
|
|
3 |
* What is BNF?
|
|
4 |
|
|
5 |
BNF is an acronym for "Backus Naur Form". John Backus and Peter Naur
|
|
6 |
introduced for the first time a formal notation to describe the syntax of a
|
|
7 |
given language (ALGOL 60 programming language).
|
|
8 |
|
|
9 |
rfc2234
|
|
10 |
|
|
11 |
* BNF syntax.
|
|
12 |
|
|
13 |
The meta-symbols of BNF are:
|
|
14 |
|
|
15 |
::=
|
|
16 |
meaning "is defined as"
|
|
17 |
|
|
|
18 |
meaning "or"
|
|
19 |
< >
|
|
20 |
angle brackets used to surround category names (some times skipped).
|
|
21 |
[ ]
|
|
22 |
optional items are enclosed in.
|
|
23 |
{ }
|
|
24 |
repetitive items (zero or more times) are enclosed in.
|
|
25 |
" "
|
|
26 |
terminals are enclosed in to distinguish them from meta-symbols.
|
|
27 |
|
|
28 |
* BNF in BNF.
|
|
29 |
|
|
30 |
syntax ::= { rule }
|
|
31 |
rule ::= identifier "::=" expression
|
|
32 |
expression ::= term { "|" term }
|
|
33 |
term ::= factor { factor }
|
|
34 |
factor ::= identifier |
|
|
35 |
quoted_symbol |
|
|
36 |
"(" expression ")" |
|
|
37 |
"[" expression "]" |
|
|
38 |
"{" expression "}"
|
|
39 |
identifier ::= letter { letter | digit }
|
|
40 |
quoted_symbol ::= """ { any_character } """
|