Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser never returns #60

Open
behzadnouri opened this issue Sep 24, 2016 · 1 comment
Open

parser never returns #60

behzadnouri opened this issue Sep 24, 2016 · 1 comment
Labels

Comments

@behzadnouri
Copy link

This is a primitve csv parser which skips intermediate blank lines:

parser :: Stream s m Char => ParsecT s u m [[String]]
parser = line `sepEndBy` (some endOfLine) <* eof
  where line = many (noneOf ",\n\r") `sepBy` char ','

and looks like it works:

\> parse parser "" "1,2,3\n\n\n4,5,6"
Right [["1","2","3"],["4","5","6"]]

but if i change some to many:

parser :: Stream s m Char => ParsecT s u m [[String]]
parser = line `sepEndBy` (many endOfLine) <* eof
  where line = many (noneOf ",\n\r") `sepBy` char ','

it will never return:

\> parse parser "" "1,2,3\n\n\n4,5,6"
^CInterrupted.
@mrkkrp
Copy link
Contributor

mrkkrp commented Sep 24, 2016

This parser gets stuck at the end of input iterating endlessly, that's why it never returns. Follow the second version in your mind step by step and you will see why. Hint: many includes zero occurences and succeeds even when there is nothing its argument can match.

@hvr hvr added the question label Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants