UP to more information about BNF, Syntax Diagrams and EBNF

BNF/EBNF variants

StyleName and linkRule ItemsConcat
(default space)
ChoiceOptional RepetitionGroupingOtherComment
TerminalNon Terminal 0 or more1 or morenn to mOther
BNF BNF (Algol 60) <name>::=... ...<...> |note1 note2note3note5
Intermediate ANSI C name:
  ...
bolditalics indented line
one of
...opt note2note3note5
BNF-like description of URLs name
  ...
...... |[...] note2note3note5
Wirth Wirth name=... . "..."... |[...] {...}note4(...)
SAIF and Bungisoft <name>::=... "..."<...> |[...] {...}note4(...)note5
EBNF from Compiler Basics by J.A.Farrell name:==... '...'... | or [...,...][...] {...}*{...}note5
Pascal EBNF Definition name
  ...
"..."
bold
<...> |[...] {...}note4(...)note5
ISO Extended Pascal name=... .
name>... .
`...'... |[...] {...}note4(...)(*...*)
ISO EBNF name=...; '...'
"..."
...,|[...] {...}{...}-n*...(...)...-...
?...?
(*...*)
ABNF EBNF from RFC822 (superceded by ABNF) name=... integer
"..."
...
<...>
 /[...]
*1...
*...1*...n*n...n*m...n#m...(...);...
ABNF (RFC2234) name=... integer
"..."
...
<...>
 /[...]
*1...
*...1*...n*n...n*m...(...);...
XBNF XBNF name::=... . "..."... |O(...) #(...)N(...)L(...,...)(...)...&...
...~...
any text not in a rule
Regular expression ISO Minimal BASIC name=... ITALICSitalics /...? ...*note4note5
EBNF for XML name::=..."..."
'...'
... |...? ...*...+(...)...-...
[wfc:...]
[vc:...]
/*...*/
... indicates some other part of the grammar e.g. a terminal literal, or a non-terminal name, or even a series of such items.

Notes:

  1. BNF can express an optional part by e.g.:
    optionalb ::= a b c d | a c d
    
  2. BNF can express 0 or more repetitions by e.g.:
    list ::=  | listitem list
    
  3. BNF can express 1 or more repetitions by e.g.:
    list ::= listitem | listitem list
    
  4. Notations that provide 0 or more repetitions but not 1 or more repetitions can simulate the latter. e.g. Wirth's EBNF can express 1 or more repetitions by e.g.:
    list : listitem { listitem }
    
  5. A grammar rule that is only instanced once is often actually being used as a comment

Here are some more versions of EBNF to be added to the table above.


UP to more information about BNF, Syntax Diagrams and EBNF

This page is maintained by and copyright © Pete Jinks [last modified 12/Mar/2004] suggestions, corrections etc. welcome You are welcome to make educational, not-for-profit use (else what would be the point!) but please give due credit.