<Two_Digit_Number> ::= <Digit> <Digit>

Above is a composite rule <Two_Digit_Number>. It is defined as being made up of a <digit> followed immediately after by a second <Digit>. We already know that a <Digit> is a single digit number from 0 to 9. As such we now, by these two rules, can define any number which is either a single digit long or two digits long. Lets see how we can derive this with the number 54. We start with the <Two_Digit_Number> rule and simply copy it down. The number 54 is known as the input.

<Two_Digit_Number> ::= <Digit> <Digit>

<Two_Digit_Number> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 <Digit>

We replace the first <Digit> non-terminal with the rule it was defined as. We always start at the left and replace rules until we get terminals. In this case we have got some digits. When we get terminals we then check our input. The first thing we see is a 5 and 5 is defiantly a digit. So we get the derivation below. Note that anything in bold was matched.

<Two_Digit_Number> ::= 5 <Digit>

<Two_Digit_Number> ::= 5 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

<Two_Digit_Number> ::= 54

At this point we have ran out of input. This means that the string has been passed. Now consider the derivation of 5A. This is clearly not valid, but we shall see how the rule would pick this up during a derivation.

<Two_Digit_Number> ::= <Digit> <Digit>

<Two_Digit_Number> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 <Digit>

<Two_Digit_Number> ::= 5 <Digit>

<Two_Digit_Number> ::= 5 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

The last line we run into a problem. The input we have left is A, however this is not one of the choices. A is not a 0 or 1 or 2 etc. This means that the input is not syntactically correct as it does not match the rules laid out in our simple grammar.