title: BNF for a hexadecimal number
body: <p>As a homework assignment I have to write a BNF definition for a hexadecimal number <code>&lt;hex&gt;</code>.</p>
  
  <p>This is to be done using <code>&lt;digit&gt;</code> and <code>&lt;letter&gt;</code>, both of which are defined as follows:</p>
  
  <pre><code>&lt;digit&gt; ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
  &lt;letter&gt; ::= A | B | C | D | E | F
  </code></pre>
  
  <p>The textbook answer is given as:</p>
  
  <pre><code>&lt;hex&gt; ::= &lt;digit&gt; | &lt;letter&gt; | &lt;hex&gt; &lt;digit&gt; | &lt;hex&gt; &lt;letter&gt;
  </code></pre>
  
  <p>I agree that this is a correct answer, but I would like to ask if it is also correct to give the answer as the following:</p>
  
  <pre><code>&lt;hex&gt; ::= &lt;digit&gt; | &lt;letter&gt; | &lt;hex&gt; &lt;hex&gt;
  </code></pre>