title: Suppress empty result from 'many' in 'seq(p, many(p))' construct with parser combinators
body: <p>I'm trying to build parser combinators following Hutton and Meijer, "Monadic Parser Combinators". My implementation is in PostScript, but I think my issue is general to combinator parsers and not my specific implementation.</p>
  
  <p>As a small exercise, I'm using the parsers to recognize regular expressions.</p>
  
  <pre><code>(pc9.ps)run
  
  /Dot         (.) char         def
  /Meta        (*+?) anyof      def
  /Character   (*+?.|()) noneof def
  
  /Atom        //Dot
               //Character  plus  def
  /Factor      //Atom  //Meta maybe  seq   def
  /Term        //Factor  //Factor many  seq  def
  /Expression  //Term  (|) char //Term xthen  many  seq  def
  
  /regex { string-input //Expression exec ps } def
  
  (abc|def|ghi) regex 
  
  quit
  </code></pre>
  
  <p>It's working, but the output has lots of <code>[]</code> empty arrays that really get in the way when I try to <code>bind</code> handlers to process the values.</p>
  
  <pre><code>$ gsnd -q -dNOSAFER pc9re2.ps
  stack:
  [[[[[97 []] [[98 []] [[99 []] []]]] [[[100 []] [[101 []] [[102 []]
  []]]] [[[103 []] [[104 []] [[105 []] []]]] []]]] null]]
  </code></pre>
  
  <p>These are happening whenever a <code>seq</code> sequencing combinator accepts the result from <code>maybe</code> or <code>many</code> (which uses <code>maybe</code>) that had zero occurrences.</p>
  
  <p>What is the normal way of excluding this extra noise in the output with Parser Combinators?</p>
  
  <p><a href="https://github.com/luser-dr00g/pcomb/tree/42c9065012d8a508208164c1b5c8778bec5fdadb" rel="nofollow noreferrer">github repo</a></p>