title: Haskell: Parsec trouble breaking out of pattern
body: <p>For reference, here is my code: <a href="http://hpaste.org/86949" rel="nofollow">http://hpaste.org/86949</a></p>
  
  <p>I am trying to parse the following expression: <code>if (a[1].b[2].c.d[999].e[1+1].f &gt; 3) { }</code>. The method playing up is <code>varExpr</code>, which parses the variable member chains.</p>
  
  <p><strong>Context</strong></p>
  
  <p>In the language I am parsing, a dot can specify accessing a member variable. Since a member variable can be another object, chains can be produced ie: <code>a.b.c</code>, or essentially <code>(a.b).c</code>. Do not assume the dots are function composition.</p>
  
  <p><strong>Implementation</strong></p>
  
  <p>The logic is like this:</p>
  
  <ul>
  <li><p>First, <code>before &lt;- many vocc</code> collects all the instances of <code>varname .</code> and their optional array expression, leaving only a single identifier left</p></li>
  <li><p><code>this &lt;- vtrm</code> collects the remaining identifier plus array expression -- the only one not proceeded by a dot</p></li>
  </ul>
  
  <p><strong>Issues</strong></p>
  
  <p>I am having two issues:</p>
  
  <p>Firstly, the first term [for a reason that I cannot determine] seems to always require that it be wrapped in brackets for the parser to accept it ie: <code>(a[1]).b[2].c...</code> -- subsequent terms do not require this. </p>
  
  <p>Secondly, the <code>many vocc</code> won't stop parsing. It always expects another identifier and another dot and I am unable to terminate the expression to catch the last <code>vtrm</code>.</p>
  
  <p>I am looking for hints or solutions that will help me solve my problem(s)/headaches. Thanks.</p>