# Why does the following Backus-Naur form reflect the following syntax diagram?

The definition of the variable

< number>::=< digit > | < digit >< number >

where < digit > is defined as

< digit > ::= 1|2|3|4|5

Apparently reflects the following syntax diagram Please explain why this is the case. I am particularly confused with the clause after the vertical OR line (i.e. < digit >< number >) and whether it has something to do with the fact that number can consist of many digits.

• It seems to me that this question would be answered by simply reading the definition of BNF grammars... Oct 4 '16 at 13:50

< number>::=< digit > | < digit >< number > means that a number is either just a digit, or a digit followed by a number. So 1 is a number (just a single digit), and 12 is also a number (a single digit, followed by a number that consists of just the single digit '2'). Similarly 123 is a number that consists of a single digit '1' and a number (that itself consists of a single digit '2' followed by a number (that consists of the single digit '3')).