title: Another way to correctly skip single line comments in javacc? <"//" (~["\n"])* "\n"> causes multi line comment skip to break
body: <p>So I am having a problem with javacc and skipping comments. I have a multi line comment skip that can contain multiply comments within itself (A comment is anything that appears within <code>/*</code> and a <code>*/</code>), I also use this code segement <code>&lt;"//" (~["\n"])* "\n"&gt;</code> to skip a single line comment. Both function independently of one another but when combined, the single line comment seems to break my multi line comment.</p>
  
  <p>The parser no longer recognises the multi line comment and instead parses it as a combination of OTHER(<code>/*</code>), ID etc.</p>
  
  <p>Below is my code for the multi line comment and single line comment skip:</p>
  
  <pre><code>SKIP:
  {
      "/*" {commentnesting++;} : IN_COMMENT
  }
  
  &lt;IN_COMMENT&gt; SKIP :
  {
      "/*" {commentnesting++;} 
      | "*/" {commentnesting--;
          if(commentnesting == 0) {
              SwitchTo(DEFAULT);
          }
      }
      | &lt;~[]&gt;
  }
  
  SKIP :
  {
      &lt;"//" (~["\n"])* "\n"&gt;
  }
  </code></pre>
  
  <p>My Questions are:</p>
  
  <ul>
  <li>How can the single line comment cause the multi line comment to break, when they to my relatively new eyes appear to have completely different regexes?</li>
  <li>Is their a way to write the single line comment skip , so that it performs the same function as before but doesn't break the multi line comment when the two are used together?</li>
  </ul>