<div class="gmail_quote">On Thu, Mar 17, 2011 at 10:58 PM, Niklas Broberg <span dir="ltr">&lt;<a href="mailto:niklas.broberg@gmail.com">niklas.broberg@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">&gt; &gt;  I already export a partial parser for top-of-file pragmas,<br><div>&gt; </div><div>&gt; I see. What I don&#39;t see is how such a parser would return the &quot;rest of input&quot;.<br></div>
<div><br></div></div><div>Hmm. I see. And I see that you are correct in not seeing it, since it appears it cannot be done with Happy, which I believed. It would then be down to the parser/lexer to pass on unconsumed input, which seems a daunting and disruptive task, seeing how the lexer typically would tokenize some input in advance before the parser discovers that it cannot consume what has been lexed... Hmm. </div>

</blockquote><div> </div><div>I think this is actually doable, although not necessarily easy, using a technique due to Oleg. He has used delimited continuations to take ordinary parsers and make them incremental. Dan Doel has experimented with applying the technique to Parsec parsers with some success. I think choosing the right parser monad in Happy can make this work.</div>

<div><br></div><div>Reference to Oleg&#39;s technique:</div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="http://okmij.org/ftp/continuations/differentiating-parsers.html">http://okmij.org/ftp/continuations/differentiating-parsers.html</a></div>

<div><br></div><div>Cheers,</div><div><br></div><div>Josef</div></div>