title: Differentiating division from regex when lexing gawk code
body: <p>I am writing a flex parser for gawk scripts. I am running into a problem differentiating between uses for a forward slash (/) character. </p>
  
  <p>Obviously, a single / would be an operator for division, but two slashes could be both a regular expression or division. Right now, it parses</p>
  
  <pre><code>int((r-1)/3)*3+int((c-1)/3)+1
  </code></pre>
  
  <p>as having the regular expression </p>
  
  <pre><code>/3)*3+int((c-1)/
  </code></pre>
  
  <p>instead of the intended division operations. How do I get flex to recognize it as a mathematical expression?</p>
  
  <p>Right now, this is my flex regular expression to recognize regular expressions in gawk:</p>
  
  <pre><code>EXT_REG_EXP "\/"("\\\/"|[^\/\n])*"\/"
  </code></pre>
  
  <p>and the division operator should be caught by my list of operators:</p>
  
  <pre><code>OPERATOR "+"|"-"|"*"|"/"|"%"|"^"|"!"|"&gt;"|"&lt;"|"|"|"?"|":"|"~"|"$"|"="
  </code></pre>
  
  <p>But since the flex regular expressions are greedy I guess it treats two divisions as a regular expression.</p>