Hi Matthias,<br><br><div class="gmail_quote">On Wed, May 30, 2012 at 1:36 PM, Matthias Hörmann <span dir="ltr"><<a href="mailto:mhoermann@gmail.com" target="_blank">mhoermann@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
parseTest (do; r1 <- anyOf ["Hello", "Hallo", "Foo", "HallofFame"]; r2 <- string "bla"; return (r1, r2)) "Hallofbla"<br>
<br>which prints this:<br><br>parse error at (line 1, column 8):unknown parse error<br><br>And my question about this is made up of two parts<br><br>1. Why doesn't it print my "unexpected" message but instead says unknown parse error<br>
2. Why is the location in the text off (I would expect it to fail at
column 6 (first character beyond the result it could return) or 7 (first
character that makes the string no prefix of any acceptable string)<br></blockquote><div><br></div><div>What version of parsec 3 are you using? In version 3.1.1, I get (using Text.Parsec.String instead of Text.Parsec.Text):</div>
<div><br></div><div><div>parse error at (line 1, column 1):</div><div>unexpected "Hallofb", expecting one of ["Hello","Hallo","Foo","HallofFame"]</div></div><div><br></div>
<div>which is what I would have expected, bearing in mind that 'try p' pretends that it hasn't consumed input when 'p' fails.</div><div><br></div><div>I don't think you need to use 'try' in your 'anyOf' function, but you'll have to change it to handle seeing the end of input if the one-character look-ahead fails.</div>
<div><br></div><div>Kevin</div><div>-- </div></div>Kevin Charter<br><a href="mailto:kevin.charter@acm.org">kevin.charter@acm.org</a><br>