[Overview] [Previous] [Next]

Expressions in BNF

You can use the structure of BNF to show the order of operations:
<expression> ::=
		<expression> + <term>
	| 	<expression>  <term>
	|	<term>

<term> ::=
		<term> * <factor>
	|	<term> / <factor>
	| 	<factor>

<factor> ::=
		<primary> ** <factor>
	|	<primary>

<primary> ::=
		<primary>
	|	<element>

<element> ::=
		( <expression> )
	|	<variable>
	| 	<number>

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