[Overview] [Previous] [Next]

More BNF Examples

Use recursion to build lists:
<statement list> ::= <statement>
	| <statement list> <statement>

You can invent new nonterminals:
<set> ::= { <element list> }

<element list> ::=
	<empty> | <nonempty element list>

<nonempty element list> ::= <element>
	| <nonempty element list> , <element>

Here's how you define the null string:
<empty> ::=

You can use multiple definitions in place of the "or":
<nonempty element list> ::= <element>

<nonempty element list> ::=
	<nonempty element list> , <element>

Copyright © 1996 by David Matuszek
Last modified Feb 2, 1996