<p dir="ltr">The second pass can be a huge problem for a failure. For example, when parsing a long string, we first look for an open parenthesis. To do so, we lex the next token. Supposing that's the string itself, we conclude that it is a string and not an open parenthesis, so we *throw it away and start over*. I hope to get the paren issue fixed for good at Hac Phi. Aside from that rather prominent one, I don't know how much the double scanning hurts, but it certainly can't *help* in most cases. In a more typical parsing situation, the parser would consume a stream of tokens instead of a list of characters. We can't do that here.</p>
<p dir="ltr">On Oct 9, 2016 12:56 AM, "wren romano" <<a href="mailto:winterkoninkje@gmail.com">winterkoninkje@gmail.com</a>> wrote:<br>
><br>
> On Sat, Oct 1, 2016 at 8:34 PM, David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br>
> > Instead of scanning first (in lexing) to find the end of the number and then<br>
> > scanning the string again to calculate the number, start to calculate once<br>
> > the first digit appears.<br>
><br>
> Ah, yes. bytestring-lexing does that (among numerous other things). It<br>
> does save a second pass over the characters, but I'm not sure what<br>
> proportion of the total slowdown of typical parser combinators is<br>
> actually due to the second pass, as opposed to other problems with the<br>
> typical "how hard can it be" lexers/parsers people knock out. Given<br>
> the multitude of other problems (e.g., using Integer or other<br>
> expensive types throughout the computation, not forcing things often<br>
> enough to prevent thunks and stack depth, etc), I'm not sure it's<br>
> legit to call it a "parser vs lexer" issue.<br>
><br>
> --<br>
> Live well,<br>
> ~wren<br>
> _______________________________________________<br>
> Libraries mailing list<br>
> <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br></p>