title: Rule cannot be matched when running flex to generate a lexical analyzer
body: <p>I am trying to write a specification for a flex lexical analyzer. One of the rules is that the identifier (e.g., "foo", "Foo_Bar", "year_2020", "Jan30") cannot end with "_", such as "foo_".
  So far I have the following to catch that error:</p>
  
  <pre><code>letter [A-Za-z]
  digit [0-9]
  identifier {letter}({letter}|{digit}|\_)*({letter}|{digit})*
  number {digit}+
  character [0-9a-zA-Z_]
  </code></pre>
  
  <p>...</p>
  
  <pre><code>    /*Ends with underscore*/
  {letter}({character}*({letter}|{number})+)?\_
  {
      printf("Error at line %d, column %d: identifier \"%s\" cannot end with an underscore.\n", num_lines, num_cols, yytext);
      exit(1);
  }
  </code></pre>
  
  <p>However I am getting an error "mini_l.lex:89: warning, rule cannot be matched", line 89 is <code>{letter}({character}*({letter}|{number})+)?\_</code>.</p>
  
  <p>Could someone please help me out?</p>